HI, I\'m taking an intro Comp. Sci. course and we have an assignment where we ha
ID: 3637399 • Letter: H
Question
HI,
I'm taking an intro Comp. Sci. course and we have an assignment where we have to compute the total cost of a cellphone bill using the python coding system. When ran the program is suppose to look like this:
Enter base voice price: 45.95
Enter voice minutes: 625
Enter price per minute: 0.00225
Enter base data price: 19.95
Enter messages: 940
Enter price per message: 0.001
Voice = $ 47.35625
Data = $ 20.89
Total = $ 68.2462
I'm very unfamiliar with python and I tried to write a code for it but after running it from gedit to python I keep getting a syntax error. I feel like it may be all sorts of messed up and any help I can get would be super.
This is my code:
# Get user input
basevoice = eval(input("Enter base voice price: "))
minutesvoice = eval(input("Enter voice minutes: "))
perminute = eval(input("Enter price per minute: "))
basedata = eval(input("Enter base data price: "))
messages = eval(input("Enter messages: "))
permessage = eval(input("Enter price per message: ")
# Evaluate total voice
totalvoice = minutevoice * perminute + basevoice
# Evaluate total data
totaldata = messages * permessage + basedata
# Evaluate total bill
total = totalvoice + totaldata
# Print output
print("Voice = $ ", totalvoice, "Data = $ ", totaldata, "Total = $ ", total)
Sorry if this is absolutely horrible. Thanks for any help in advance.
Explanation / Answer
Here is your code. I have modified a bit and its working in my computer. # Get user input basevoice = input("Enter base voice price: ") minutesvoice = input("Enter voice minutes: ") perminute = input("Enter price per minute: ") basedata = input("Enter base data price: ") messages = input("Enter messages: ") permessage = input("Enter price per message: ") # Evaluate total voice totalvoice = minutesvoice*perminute + basevoice # Evaluate total data totaldata = messages*permessage + basedata # Evaluate total bill total = totalvoice + totaldata # Print output print('Voice = ', totalvoice, "Data = ",totaldata, 'Total = ', total); I hope this answers your question. If you have any further query then feel free to ask! :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.