In: Computer Science
Write a single statement that prompts the user to enter their age in years and places the integer value in a variable named age.
Write a short code segment in Python that prompts the user to enter the number of quarters, dimes, nickels and pennies they have, compute the total value and print that value
What convention is considered “standard” for the naming of variables and functions, in order to improve the readability of code?
What type of error will occur due to the following Python statement? - Class = “Type II”
Using decimal scientific literal notation, write the number 314,159.
The standard convention to name variables in python is, you should use only lower case alphabets and words in the variable name must be separated by underscores.
I don't think there should be any error with just this statement, but if you type class with a lower case, you should get an invalid syntax error because class is a keyword in python.
the
e is used to denote the power of 10.
if the answer helped you please upvote and if you have any doubts please comment i will surely help. please take care of the indentation while copying the code. Check from the screenshots provided.
Code:
age = int(input("Enter your age: "))
quarters = int(input("Enter the number of quarters: "))
dimes = int(input("Enter the number of dimes: "))
nickels = int(input("Enter the number of nickels: "))
pennies = int(input("Enter the number of pennies: "))
total_cost = quarters*0.25 + dimes*0.10 + nickels*0.05 +
pennies*0.01
print(f"The total cost in dollars is {total_cost}$")