In python 3:
def word_count(txt):
lst = txt.lower().split()
dict = {}
new_txt = ""
for i in lst:
if i not in new_txt:
new_txt += i
dict[i] = txt.lower().count(i)
return dict
print(word_count("Rock ties with rock"))
I hope this helps!
Answer:
def count_words(txt):
lst = txt.split(",")
var = {}
for i in lst:
if i in var:
var[i]+= 1
else:
var[i] = 1
return var
print(word_count("Rock ties with Rock"))
Explanation:
This one worked for me, hopefully it's what you were asking.
Cable television systems originated with the invention of a particular component. What was this component called?
Answer:
Cable television is a system of delivering television programming to consumers via radio frequency (RF) signals transmitted through coaxial cables, or in more recent systems, light pulses through fibre-optic cables. This contrasts with broadcast television (also known as terrestrial television), in which the television signal is transmitted over the air by radio waves and received by a television antenna attached to the television; or satellite television, in which the television signal is transmitted by a communications satellite orbiting the Earth and received by a satellite dish on the roof. FM radio programming, high-speed Internet, telephone services, and similar non-television services may also be provided through these cables. Analog television was standard in the 20th century, but since the 2000s, cable systems have been upgraded to digital cable operation.Explanation:
[tex]hii[/tex]have a nice day ✌️✌️Cable television systems originated with the invention of a particular component. The component is a coaxial cable. The correct option is A.
What is a cable television system?Radiofrequency (RF) signals are transferred through coaxial cables, or in more current systems, light pulses are transmitted through fiber-optic cables, to deliver television programming to viewers via cable television networks.
This is in contrast to satellite television, which transmits the television signal via a communications satellite orbiting the Earth and receives it via a satellite dish.
It broadcast television, in which the television signal is transmitted over the air by radio waves and received by a television antenna attached to the television.
Therefore, the correct option is A. coaxial cable.
To learn more about the cable television system, refer to the link:
https://brainly.com/question/29059599
#SPJ2
The question is incomplete. Your most probably complete question is given below:
A. coaxial cable
B. analog transmission
C. digital transmission
D. community antenna
You want to look up colleges but exclude private schools. Including punctuation, what would you
type?
O nonprofit college
O college -private
O private -college
O nonprofit -college
You want to look up colleges but exclude private schools. Including punctuation, The type is private -college. The correct option is c.
What are institutions of higher studies?The institutions for higher studies are those institutions that provide education after schooling. They are colleges and universities. Universities, colleges, and professional schools that offer training in subjects like law, theology, medicine, business, music, and art are all considered higher education institutions.
Junior colleges, institutes of technology, and schools for future teachers are also considered to be part of higher education. There are different types of colleges, like government colleges and private colleges. Private colleges are those which are funded by private institutions.
Therefore, the correct option is c. private -college.
To learn more about excluding, refer to the link:
https://brainly.com/question/27246973
#SPJ2
Type the correct answer in the box
in which phishing technique are URLs of the spoofed organization misspelled?
anon
is a phishing technique in which URLs of the spoofed organization are misspelled
Answer: Link manipulation
Explanation:
Answer:
Typo Squatting
Explanation:
There is a company of name "Baga" and it produces differenty kinds of mobiles. Below is the list of model name of the moble and it's price model_name Price reder-x 50000 yphone 20000 trapo 25000 Write commands to set the model name and price under the key name as corresponding model name how we can do this in Redis ?
Answer:
Microsoft Word can dohjr iiejdnff jfujd and
Microsoft Word can write commands to set the model name and price under the key name as corresponding model.
What is Microsoft word?One of the top programs for viewing, sharing, editing, managing, and creating word documents on a Windows PC is Microsoft Word. The user interface of this program is straightforward, unlike that of PaperPort, CintaNotes, and Evernote.
Word documents are useful for organizing your notes whether you're a blogger, project manager, student, or writer. Because of this, Microsoft Word has consistently been a component of the Microsoft Office Suite, which is used by millions of people worldwide.
Although Microsoft Word has traditionally been connected to Windows PCs, the program is also accessible on Mac and Android devices. The most recent version of Microsoft Office Word.
Therefore, Microsoft Word can write commands to set the model name and price under the key name as corresponding model.
To learn more about microsoft word, refer to the link:
https://brainly.com/question/26695071
#SPJ5
Works in the public domain have copyright that are expired or abandoned true or false
Answer:
False
Explanation:
Only one of the two are true. Works in the public domain have a copyright that has expired only. E.g. Works of classical music artist, are almost always expired, in accorance with American Copyright law. Abandoning a copyright doesn't do anything because so long the copyright has remained unexpired, the copyright remains. Thats why it can take decades for a new movie in a series to release, like "IT" by Stephen King. The copyright hasn't expired but rather was 'abandoned'. Before "IT" 2017 was relasesed, the copyright was abandoned.
1.2
Is media a curse or a blessing? Explain.
Answer:
i think its both because if there is misunderstanding between media and government then the media distroys the government and if there us no misunderstanding between media and government and if it goes smoothly then its like a blessing for government
Answer:
Media is a blessing...a curse as well when it's misguiding the world and hiding the real sinner and juxtaposing the culprit as the saviour
Select the items that you may see on a Windows desktop.
Shortcuts to frequently used programs
System tray
Recycle Bin
Taskbar
O Database
Icons
O Quick Launch
Answer:
You may see:
The taskbar
The startmenu
Program icons within the taskbar
Shortcuts
Documents
Folders
Media files
Text files
The Recycle Bin
and so on...
the company has finished designing a software program but users aren't sure how to use it
Answer:
The company should go back into the company and make it a little more easier to use or the company should put out an announcement or something so the people trying to use it know how
Explanation:
Mark me the brainliest please and rate me
Answer:
Several people in the human resources department need new software installed. An employee has an idea for a software program that can save the company time, but doesn't know how to write it.
Explanation:
Language: C
Introduction
For this assignment you will write an encoder and a decoder for a modified "book cipher." A book cipher uses a document or book as the cipher key, and the cipher itself uses numbers that reference the words within the text. For example, one of the Beale ciphers used an edition of The Declaration of Independence as the cipher key. The cipher you will write will use a pair of numbers corresponding to each letter in the text. The first number denotes the position of a word in the key text (starting at 0), and the second number denotes the position of the letter in the word (also starting at 0). For instance, given the following key text (the numbers correspond to the index of the first word in the line):
[0] 'Twas brillig, and the slithy toves Did gyre and gimble in the wabe;
[13] All mimsy were the borogoves, And the mome raths outgrabe.
[23] "Beware the Jabberwock, my son! The jaws that bite, the claws that catch!
[36] Beware the Jubjub bird, and shun The frumious Bandersnatch!"
[45] He took his vorpal sword in hand: Long time the manxome foe he sought—
The word "computer" can be encoded with the following pairs of numbers:
35,0 catch
5,1 toves
42,3 frumious
48,3 vorpal
22,1 outgrabe
34,3 that
23,5 Beware
7,2 gyre
The .cpp code is avaiable bellow
Code:
#include <stdio.h>
#include <string.h>
int main()
{
char **kW;
char *fN;
int nW = 0;
kW = malloc(5000 * sizeof(char*));
for (int i = 0; i<5000; i++)
{
kW[i] = (char *)malloc(15);
}
fN = (char*)malloc(25);
int choice;
while (1)
{
printf("1) File text to use as cipher\n");
printf("2) Make a cipher with the input text file and save result as output file\n");
printf("3) Decode existing cipher\n");
printf("4) Exit.\n");
printf("Enter choice: ");
scanf("%d", &choice);
if (choice == 1)
{
nW = readFile(kW, fN);
}
else if (choice == 2)
{
encode(kW, fN, nW);
}
else
{
Exit();
}
printf("\n");
}
return 0;
}
int readFile(char** words, char *fN)
{
FILE *read;
printf("Enter the name of a cipher text file:");
scanf("%s", fN);
read = fopen(fN, "r");
if (read == NULL)
{
puts("Error: Couldn't open file");
fN = NULL;
return;
}
char line[1000];
int word = 0;
while (fgets(line, sizeof line, read) != NULL)
{
int i = 0;
int j = 0;
while (line[i] != '\0')
{
if (line[i] != ' ')
{
if (line[i] >= 65 && line[i] <= 90)
{
words[word][j] = line[i]; +32;
}
else
{
words[word][j] = line[i];
}
j++;
}
else
{
words[word][j] = '\n';
j = 0;
word++;
}
i++;
}
words[word][j] = '\n';
word++;
}
return word;
}
void encode(char** words, char *fN, int nwords)
{
char line[50];
char result[100];
if (strcmp(fN, "") == 0)
{
nwords = readFile(words, fN);
}
getchar();
printf("Enter a secret message(and press enter): ");
gets(line);
int i = 0, j = 0;
int w = 0, k = 0;
while (line[i] != '\0')
{
if (line[i] >= 65 && line[i] <= 90)
{
line[i] = line[i] + 32;
}
w = 0;
int found = 0;
while (w<nwords)
{
j = 0;
while (words[w][j] != '\0')
{
if (line[i] == words[w][j])
{
printf("%c -> %d,%d \n", line[i], w, j);
found = 1;
break;
}
j++;
}
if (found == 1)
break;
w++;
}
i++;
}
result[k] = '\n';
}
void Exit()
{
exit(0);
}
What is a piece of information sent to a function
Answer:
the information sent to a function is the 'input'.
or maybe not hehe
What does the measurement tell you?
Schedule performance index
Answer:
how close the project is to being completed compared to the schedule/ how far ahead or behind schedule the project is, relative to the overall project
Explanation:
Your program is going to compare the distinct salaries of two individuals for the last 5 years. If the salary for the two individual for a particular year is exactly the same, you should print an error and make the user enter both the salaries again for that year. (The condition is that there salaries should not be the exact same).Your program should accept from the user the salaries for each individual one year at a time. When the user is finished entering the salaries, the program should print which individual made the highest total salary over the 5 year period. This is the individual whose salary is the highest.You have to use arrays and loops in this assignment.In the sample output examples, what the user entered is shownin italics.Welcome to the winning card program.
Enter the salary individual 1 got in year 1>10000
Enter the salary individual 2 got in year 1 >50000
Enter the salary individual 1 got in year 2 >30000
Enter the salary individual 2 got in year 2 >50000
Enter the salary individual 1 got in year 3>35000
Enter the salary individual 2 got in year 3 >105000
Enter the salary individual 1 got in year 4>85000
Enter the salary individual 2 got in year 4 >68000
Enter the salary individual 1 got in year 5>75000
Enter the salary individual 2 got in year 5 >100000
Individual 2 has the highest salary
In python:
i = 1
lst1 = ([])
lst2 = ([])
while i <= 5:
person1 = int(input("Enter the salary individual 1 got in year {}".format(i)))
person2 = int(input("Enter the salary individual 1 got in year {}".format(i)))
lst1.append(person1)
lst2.append(person2)
i += 1
if sum(lst1) > sum(lst2):
print("Individual 1 has the highest salary")
else:
print("Individual 2 has the highest salary")
This works correctly if the two individuals do not end up with the same salary overall.
Ms. Myers commented that _____ she slept in at the hotel was better than _____ she slept in at home.
Write a program that finds the number of items above the average of all items. The problem is to read 100 numbers, get the average of these numbers, and find the number of the items greater than the average. To be flexible for handling any number of input, we will let the user enter the number of input, rather than fixing it to 100.
Answer:
Written in Python
num = int(input("Items: "))
myitems = []
total = 0
for i in range(0, num):
item = int(input("Number: "))
myitems.append(item)
total = total + item
average = total/num
print("Average: "+str(average))
count = 0
for i in range(0,num):
if myitems[i] > average:
count = count+1
print("There are "+str(count)+" items greater than average")
Explanation:
This prompts user for number of items
num = int(input("Items: "))
This creates an empty list
myitems = []
This initializes total to 0
total = 0
The following iteration gets user input for each item and also calculates the total
for i in range(0, num):
item = int(input("Number: "))
myitems.append(item)
total = total + item
This calculates the average
average = total/num
This prints the average
print("Average: "+str(average))
This initializes count to 0
count = 0
The following iteration counts items greater than average
for i in range(0,num):
if myitems[i] > average:
count = count+1
This prints the count of items greater than average
print("There are "+str(count)+" items greater than average")
Which of the following best describes open-source code software?
O A. a type of software that is open to the public and can be modified
B. a type of software that is free to download, but cannot be modified
C. a type of software that is locked, but can be modified
D. a type of software that has already been modified
Answer:
A. a type of software that is open to the public and can be modified.
Explanation:
Open-source refers to anything that is released under a license in which the original owner grants others the right to change, use, and distribute the material for any purpose.
Open-source code software is described as a type of software that is open to the public and can be modified. The correct option is A.
What is open-source code?Open-source software is computer software that is distributed under a licence that allows users to use, study, change, and distribute the software and its source code to anyone and for any purpose.
Open-source software can be created collaboratively and publicly. Open-source refers to anything that is released under a licence that allows others to change, use, and distribute the material for any purpose.
Therefore, open-source code software is defined as software that is freely available to the public and can be modified. A is the correct answer.
To know more about open-source code follow
https://brainly.com/question/15039221
#SPJ6
Assume you are using an array-based queue and have just instantiated a queue of capacity 10. You enqueue 5 elements, dequeue 5 elements, and then enqueue 1 more element. Which index of the internal array elements holds the value of that last element you enqueued
Answer:
The answer is "5".
Explanation:
In the queue based-array, it follows the FIFO method, and in the question, it is declared that a queue has a capacity of 10 elements, and insert the 5 elements in the queue and after inserting it enqueue 5 elements and at the last, it inserts an element 1 more element on the queue and indexing of array always start from 0, that's why its last element index value is 5.
Question 8 (3 points) Which of the following is an external factor that affects the price of a product? Choose the answer.
sales salaries
marketing strategy
competition
production cost
Answer: tax
Explanation: could effect the cost of items because the tax makes the price higher
oh sorry i did not see the whole question
this is the wrong awnser
Complete the following sentences using the drop-down menus.
is considered by some to be the most important program because of its popularity and wide use.
applications are used to display slide show-style presentations.
programs have revolutionized the accounting industry.
Answer:
is considered by some to be the most important program because of its popularity and wide use.
✔ Presentation
applications are used to display slide show-style presentations.
✔ Spreadsheet
programs have revolutionized the accounting industry.
Explanation:
just did it on edg this is all correct trust
the answers are:
- presentation
- spreadsheet
The hide/unhide feature only hides in the
_____ view?
Answer: main...?
Explanation:
To write a letter using Word Online, which document layout should you choose? ASAP PLZ!
Traditional... See image below
Answer: new blank document
Explanation: trust is key
Write a function that takes a string and return the back half of the string. If the string has an odd number of characters, include the extra character. Your solution should also work if given and empty string. Examples: back_half('abba') should return 'ba' back_half('abcba') should return 'cba'
Answer:
Written in Python
def back_half(inputstring):
outputstring = ""
lent = len(inputstring)
if lent == 0:
outputstring ="Empty String"
elif lent%2 == 0:
begin = lent/2
for i in range(int(begin),lent):
outputstring = outputstring + inputstring[i]
else:
begin = (lent+1)/2
for i in range(int(begin-1),lent):
outputstring = outputstring + inputstring[i]
return outputstring
Explanation:
This line defines the function
def back_half(inputstring):
This line initializes outputstring to an empty string
outputstring = ""
This calculates the length of the input string
lent = len(inputstring)
This checks if the length of inputstring is 0. If yes, the function returns empty string
if lent == 0:
outputstring ="Empty String"
This checks if the length of inputstring is even.
elif lent%2 == 0:
begin = lent/2 This line gets the beginning of the half string
for i in range(int(begin),lent):
outputstring = outputstring + inputstring[i] This generates the half string
else: This checks for odd length
begin = (lent+1)/2 This line gets the beginning of the half string
for i in range(int(begin-1),lent):
outputstring = outputstring + inputstring[i] This generates the half string
return outputstring This returns the outputstring
Reading for comprehension requires _____ reading?
1. passive
2. active
3. slow
4. fast
Answer:
IT is ACTIVE
Explanation: I took the quiz
Answer:
not sure sorry
Explanation:
Explain why it is not necessary for a program to be completely free of defects before it is delivered to its customers?
Answer:
Testing is done to show that a program is capable of performing all of its functions and also it is done to detect defects.
It is not always possible to deliver a 100 percent defect free program
A program should not be completely free of all defects before they are delivered if:
1. The remaining defects are not really something that can be taken as serious that may cause the system to be corrupt
2. The remaining defects are recoverable and there is an available recovery function that would bring about minimum disruption when in use.
3. The benefits to the customer are more than the issues that may come up as a result of the remaining defects in the system.
Which online text source would include a review of a new TV show?
an academic journal
a blog
an e-book
an encyclopedia
Answer:
Blog
Explanation:
Online text sources include blogs, e-books, encyclopaedias, and e-zines. As a result, options A, B, C, and D are correct.
What is a text source?A source is a book or other material that contains the data that has been used, whereas a citation is the actual statement of the starting point. They were researchers who also worked as professors, writers, and other professionals, and they published books and articles.
Online text sources are those that can be accessed from anywhere and are available on the internet. The online text shows that anyone can see or exceed including blogs, e-books, encyclopaedias, and e-zines.
These are available for further studies and research. Also to give information this can be a source. Therefore, options A, B, C, and E is the correct option.
Learn more about text sources, here:
brainly.com/question/19131568
#SPJ6
This assignment requires you to write a program to analyze a web page HTML file. Your program will read one character at a time from the file specifying the web page, count various attributes in the code for the page, and print a report to the console window giving information about the coding of the page.
Note that a search engine like Google uses at least one technique along similar lines. To calculate how popular (frequently visited or cited) a web page is, one technique is to look at as many other worldwide web pages as possible which are relevant, and count how many links the world's web pages contain back to the target page.
Learning Objectives
To utilize looping structures for the first time in a C++ program
To develop more sophisticated control structures using a combination of selection and looping
To read data from an input file
To gain more experience using manipulators to format output in C++
To consider examples of very simple hypertext markup language (HTML)
Use UNIX commands to obtain the text data files and be able to read from them
Problem Statement
Your program will analyze a few things about the way in which a web page is encoded. The program will ask the user for the name of a file containing a web page description. This input file must be stored in the correct folder with your program files, as discussed in class, and it must be encoded using hypertext markup language, or HTML. The analysis requires that you find the values of the following items for the page:
number of lines (every line ends with the EOLN marker; there will be an EOLN in front of the EOF)
number of tags (includes links and comments)
number of links
number of comments in the file
number of characters in the file (note that blanks and EOLNs do count)
number of characters inside tags
percentage of characters which occur inside tags, out of the total
Here is an example of a very simple HTML file:
Course Web Page
This course is about programming in C++.
Click here
You may assume that the HTML files you must analyze use a very limited subset of basic HTML, which includes only the following "special" items:
tag always starts with '<' and ends with >
link always starts with "
comment always starts with ""
You may assume that a less-than symbol (<) ALWAYS indicates the start of a tag. A tag in HTML denotes an item that is not displayed on the web page, and often gives instructions to the web browser. For example, indicates that the next item is the overall title of the document, and indicates the end of that section. In tags, both upper and lowercase letters can be used.
Note on links and comments: to identify a link, you may just look for an 'a' or 'A' which occurs just after a '<'. To identify a comment, you may just look for a '!' which follows just after a '' (that is, you do not have to check for the two hyphens).
You may assume that these are the only HTML language elements you need to recognize, and that the HTML files you process contain absolutely no HTML syntax errors.
Note: it is both good style because readability is increased, and convenient, to declare named constants for characters that are meaningful, for example
const char TAG OPEN = '
Sample Input Files
Program input is to be read from a text file. Your program must ask the user for interactive input of the file name. You can declare a variable to store the file name and read the user's response
Miscellaneous Tips and Information
You should not read the file more than once to perform the analysis. Reading the file more than once is very inefficient.
The simplest, most reliable and consistent way to check for an end of file condition on a loop is by checking for the fail state, as shown in lectures. The eof function is not as reliable or consistent and is simply deemed "flaky" by many programmers as it can behave inconsistently for different input files and on different platforms.
You may use only while loops on this project if you wish; you are not required to choose amongst while, do while and/or for loops until project 4 and all projects thereafter. Do not create any functions other than main() for this program. Do not use data structures such as arrays. You may only have ONE return statement and NO exit statements in your code. You may only use break statements inside a switch statement in the manner demonstrated in class; do not use break or continue statements inside loops.
#include // used for interactive console I/O
#include // used to format output
#include // used to retrieve data from file
#include // used to convert data to uppercase to simplify comparisons
#include 11 for string class functions
int main() { 1
//constants for analysing HTML attributes
const char EOLN = '\n';
const char COMMENT_MARK = '!';
const char LINK='A';
//constants to format the output
const int PAGEWIDTH = 70;
const char UNDERLINE = '=';
const char SPACE =
const int PCT_WIDTH = 5;
const int PCT_PRECISION = 2;
Answer:
bro it is a question what is this
Explanation:
please follow me
Which situation best illustrates how traditional economies meet their citizens needs for employment and income
APEX!!
A. A parent teaches a child to farm using centuries old techniques.
B. A religious organization selects a young person to become a priest
C. A government agency assigns a laborer a job working in a factory
D. A corporation hires an engineer who has just graduated from college
The situation that best show how traditional economies meet their citizens needs for employment and income is that a parent teaches a child to farm using centuries old techniques.
What is a traditional economy about?A traditional economy is known to be a type of system that depends on customs, history, and time framed/honored beliefs.
Tradition is know to be the guide that help in economic decisions such as production and distribution. Regions with traditional economies are known to depend on agriculture, fishing, hunting, etc.
Learn more about traditional economies from
https://brainly.com/question/620306
When investigators find evidentiary items that aren't specified in a warrant or under probable cause what type of doctrine applies
In this exercise you will debug the code which has been provided in the starter file. The code is intended to take two strings, s1 and s2 followed by a whole number, n, as inputs from the user, then print a string made up of the first n letters of s1 and the last n letters of s2. Your job is to fix the errors in the code so it performs as expected (see the sample run for an example).
Sample run
Enter first string
sausage
Enter second string
races
Enter number of letters from each word
3
sauces
Note: you are not expected to make your code work when n is bigger than the length of either string.
1 import java.util.Scanner;
2
3 public class 02_14_Activity_one {
4 public static void main(String[] args) {
5
6 Scanner scan = Scanner(System.in);
7
8 //Get first string
9 System.out.println("Enter first string");
10 String s1 = nextLine(); 1
11
12 //Get second string
13 System.out.println("Enter second string");
14 String s2 = Scanner.nextLine();
15
16 //Get number of letters to use from each string
17 System.out.println("Enter number of letters from each word");
18 String n = scan.nextLine();
19
20 //Print start of first string and end of second string
21 System.out.println(s1.substring(1,n-1) + s2.substring(s1.length()-n));
22
23
24 }
Answer:
Here is the corrected program:
import java.util.Scanner; //to accept input from user
public class 02_14_Activity_one { //class name
public static void main(String[] args) { //start of main method
Scanner scan = new Scanner(System.in); //creates Scanner class object
System.out.println("Enter first string"); //prompts user to enter first string
String s1 = scan.nextLine(); //reads input string from user
System.out.println("Enter second string"); //prompts user to enter second string
String s2 = scan.nextLine(); //reads second input string from user
System.out.println("Enter number of letters from each word"); //enter n
int n = scan.nextInt(); //reads value of integer n from user
System.out.println(s1.substring(0,n) + s2.substring(s2.length() - n ));
} } //uses substring method to print a string made up of the first n letters of s1 and the last n letters of s2.
Explanation:
The errors were:
1.
Scanner scan = Scanner(System.in);
Here new keyword is missing to create object scan of Scanner class.
Corrected statement:
Scanner scan = new Scanner(System.in);
2.
String s1 = nextLine();
Here object scan is missing to call nextLine() method of class Scanner
Corrected statement:
String s1 = scan.nextLine();
3.
String s2 = Scanner.nextLine();
Here class is used instead of its object scan to access the method nextLine
Corrected statement:
String s2 = scan.nextLine();
4.
String n = scan.nextLine();
Here n is of type String but n is a whole number so it should be of type int. Also the method nextInt will be used to scan and accept an integer value
Corrected statement:
int n = scan.nextInt();
5.
System.out.println(s1.substring(1,n-1) + s2.substring(s1.length()-n));
This statement is also not correct
Corrected statement:
System.out.println(s1.substring(0,n) + s2.substring(s2.length() - n ));
This works as follows:
s1.substring(0,n) uses substring method to return a new string that is a substring of this s1. The substring begins at the 0th index of s1 and extends to the character at index n.
s2.substring(s2.length() - n ) uses substring method to return a new string that is a substring of this s2. The substring then uses length() method to get the length of s2 and subtracts integer n from it and thus returns the last n characters of s2.
The screenshot of program along with its output is attached.
For this lab you will do 2 things:
Solve the problem in an algorithm
Code it in Python
Problem:
Cookie Calories
A bag of cookies holds 40 cookies. The calorie information on the bag claims that there are 10 "servings" in the bag and that a serving equals 300 calories. Write a program that asks the user to input how many cookies he or she ate and the reports how many total calories were consumed.
*You MUST use constants to represent the number of cookies in the bag, number of servings, and number of calories per serving. Remember to put constants in all caps!
Make sure to declare and initialize all variables before using them!
Then you can do the math using those constants to find the number of calories in each cookie.
Make this program your own by personalizing the introduction and output.
Sample Output:
WELCOME TO THE CALORIE COUNTER!!
Answer:
Here is the Python program:
COOKIES_PER_BAG = 40 #sets constant value for bag of cookies
SERVINGS_PER_BAG = 10 #sets constant value for serving in bag
CALORIES_PER_SERVING = 300 #sets constant value servings per bag
cookies = int(input("How many cookies did you eat? ")) #prompts user to input how many cookies he or she ate
totalCalories = cookies * (CALORIES_PER_SERVING / (COOKIES_PER_BAG / SERVINGS_PER_BAG)); #computes total calories consumed by user
print("Total calories consumed:",totalCalories) #displays the computed value of totalCalories consumed
Explanation:
The algorithm is:
StartDeclare constants COOKIES_PER_BAG, SERVINGS_PER_BAG and CALORIES_PER_SERVINGSet COOKIES_PER_BAG to 40Set SERVINGS_PER_BAG to 10Set CALORIES_PER_SERVING to 300Input cookiesCalculate totalCalories: totalCalories ← cookies * (CALORIES_PER_SERVING / (COOKIES_PER_BAG / SERVINGS_PER_BAG))Display totalCaloriesI will explain the program with an example:
Lets say user enters 5 as cookies he or she ate so
cookies = 5
Now total calories are computed as:
totalCalories = cookies * (CALORIES_PER_SERVING / (COOKIES_PER_BAG / SERVINGS_PER_BAG));
This becomes:
totalCalories = 5 * (300/40/10)
totalCalories = 5 * (300/4)
totalCalories = 5 * 75
totalCalories = 375
The screenshot of program along with its output is attached.
Alice just wrote a new app using Python. She tested her code and noticed some of her lines of code are out of order. Which principal of programing should Alice review?
Answer:
sequencing
Explanation:
from flvs
Answer:
Sequencing
Explanation: