Question

In: Computer Science

Python #Note: use print() to add spaces between items and when needed in the receipt #(e.g....

Python

#Note: use print() to add spaces between items and when needed in the receipt
#(e.g. between user entries and between the entries and the receipt)

#1 Ask the user for a number using the prompt: NUMBER?
# Convert the user entered number to an integer
# Calculate the square of the number and display the result on screen with the following text before it: Your number squared is

#2 Ask the user for a first number using the prompt: first number?
# Ask the user for a second number using the prompt: second number?
# Convert the two numbers to integers
# Multiply the first number by the second number and display the result on screen with the following text before it: Result:
"""
#3 Develop a simple food receipt
a. Ask the user for inputs about two food items using the following prompts in turn. Do not forget to assign each user
entry to a unique variable name:
Item1 name?
Item1 price?
Item1 quantity?
  
Item2 name?
Item2 price?
Item2 quantity?
  
b. Convert the price and quantity variables to integers
c. Calculate the total cost for the order by calculating each item's total price by
multiplying price and quantity for each item and then adding up the total prices for the two items
d. Display the results using the format:
RECEIPT
You ordered: [item1 name] and [item2 name]
Total cost: $ [total price for both items calculated in 3c above]

"""
#Start your code below

"""
Enhance your simple food receipt
a. Ask the user for inputs about two food items using the following prompts in turn. Do not forget to assign each user
entry to a unique variable name:
First item name?
First item price?
First item quantity?
  
Second item name?
Second item price?
Second item quantity?
  
Third item name?
Third item price?
Third item quantity?
  
b. Convert the price and quantity variables to integers
c. Calculate the total cost for the order by calculating each item's total price by
multiplying price and quantity for each item and then adding up the total prices for the three items
d. Calculate the total cost plus tax for the order by multiplying the total cose calculated in c by the tax rate of .09
then adding the tax to the total cost
e. Display the results using the format:
RECEIPT
You ordered: [First item name] [Second item name] [third item name]
Total cost: $ [total price for all items calculated in 3c above]
Total cost plus tax: $ {total cost plus tax calculated in 3d above}

"""
#Start your code below

Solutions

Expert Solution

Code 1 Python 3

============================================================================================

#input from user
num=input('NUMBER? ')
# Convert the user entered number to an integer
num=int(num)

# Calculate the square of the number and display the result on screen with the following text
num=num*num
print('Your number squared is: ',num)

============================================================================================

Output

============================================================================================

Code 2

# Ask the user for a first number using the prompt
num1=input('first number? ')
# Ask the user for a second number using the prompt:
num2=input('second number? ')

# Convert the two numbers to integers
num1=int(num1)
num2=int(num2)

# Multiply the first number by the second number and display the result on screen with the following text before it:
res=num1*num2
print('Result: ',res)

============================================================================================

Output

============================================================================================


Related Solutions

Python #Note: use print() to add spaces between items and when needed in the receipt #(e.g....
Python #Note: use print() to add spaces between items and when needed in the receipt #(e.g. between user entries and between the entries and the receipt) #1 Ask the user for a number using the prompt: NUMBER? # Convert the user entered number to an integer # Calculate the square of the number and display the result on screen with the following text before it: Your number squared is #2 Ask the user for a first number using the prompt:...
Initialize an empty hashtable, programmatically add 5 items (colors, names, fruits, etc.), use Write-Host to print...
Initialize an empty hashtable, programmatically add 5 items (colors, names, fruits, etc.), use Write-Host to print the keys and values separately, then remove one of the items and print the entire hashtable POWERSHELL PLEASE!
1.Suppose a dictionary Groceries maps items to quantities.     Write a python to print the names...
1.Suppose a dictionary Groceries maps items to quantities.     Write a python to print the names of the grocery items whose quantity exceeds 400.     For example, if groceries = {‘cake mixes’: 430, ‘cheese’:312, ‘Orange’:525, ‘candy bars’: 217}         The output will be                                 Cake mixes                                 Orange 2. which Python string method would be the best choice to print the number of time “the” occurs in a sentence entered by the user? Provide a one word answer. Just...
(Python) This is my code for printing a roster for a team. When I print to...
(Python) This is my code for printing a roster for a team. When I print to the console, it makes the first player's name show up as number 2, and it says [] (its just blank for 1). How can I fix that so the first player's name is 1, not skipping 1 and going to 2. def file_to_dictionary(rosterFile): myDictionary={} myDict=[]    with open(rosterFile,'r') as f: for line in f:    (num,first,last,position)=line.split() myDictionary[num]= myDict myDict=[first, last, position] print (myDictionary) return...
Write a Python program to (a) create a new empty stack. Then, (b) add items onto...
Write a Python program to (a) create a new empty stack. Then, (b) add items onto the stack. (c) Print the stack contents. (d) Remove an item off the stack, and (e) print the removed item. At the end, (f) print the new stack contents:
using python 3 1. Two-line input: print a prompt (e.g Enter your first name) and then...
using python 3 1. Two-line input: print a prompt (e.g Enter your first name) and then assign the input to a variable print ("Enter your first name")# the word prompt is the message the user should see firstName = input() print (firstName)
Add the result envidented by the python compiler. use python language. 1(a) A Give the output...
Add the result envidented by the python compiler. use python language. 1(a) A Give the output for the array([ 0, 1, 8, 27, 64, 125, 216, 343, 512, 729]) a. a[:6:2] = -1000 (ii) a[ : :-1] ) b. Display the values of 1D array using for loop?
 c. Write a code to print a 3D array?
 d. How to print the transpose of a 2D array?
 e Write a function to sort the array row and coloumn wise ?...
On Python a) Use format() method to print an integer value entered by the user and...
On Python a) Use format() method to print an integer value entered by the user and its cube root with two decimal places. b) Print the same values as part (a) using format() function with keyword arguments and labels number and cubeRoot as in: format(number=n,cubeRoot=cr) c) Switch the order of keyword arguments and show that this has no effect on the output.
Python #For question 1 and 2 you may not use ''' ''' Question 1 Print the...
Python #For question 1 and 2 you may not use ''' ''' Question 1 Print the messages below without using variables. Output must be 2 lines identical to below: What is the snake's favorite language? "I love Python", said the snake. Question 2 Write a python statements to match the 5 lines of output below. Use a single print statement to produce the list of 4 languages The 3 most popular programming languages of 2020 are: 1.         Python 2.         Javascript 3.         Java 4.         C#...
Important: please use python. Using while loop, write python code to print the times table (from...
Important: please use python. Using while loop, write python code to print the times table (from 0 to 20, incremented by 2) for number 5. Add asterisks (****) so the output looks exactly as shown below.   Please send the code and the output of the program. ****************************************************************** This Program Shows Times Table for Number 5 (from 0 to 20) Incremented by 2 * ****************************************************************** 0 x 5 = 0 2 x 5 = 10 4 x 5 = 20 6...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT