Questions Uploads

input (“(B)udget, (D)aily, or (W)eekly rental

i get an error with my script and am not sure why since i have averageWeeklyMiles = totalMiles/rentalPeriod ? it says nameError: name ‘averageDayMiles’ is not defined codio@sister-janet:~/workspace$ Here is my script in Python

import sys

#ask user for input of type of rental

rentalCode = input (“(B)udget, (D)aily, or (W)eekly rental?”)

if rentalCode == “B” or rentalCode == “D”:

  rentalPeriod = int(input(“Number of Days Rented: “))

else:

   rentalPeriod = int(input(“Number of Weeks Rented: “)) 

budgetCharge = 40.00

dailyCharge = 60.00

weeklyCharge = 190.00   

if rentalCode == “B”:

 #calulate charges depending on input from above

 baseCharge= rentalPeriod * 40.00

elif rentalCode == “D”:

  baseCharge= rentalPeriod * 60.00

else:

   baseCharge= rentalPeriod * 190.00

odoStart = (input (“Starting Odometer Reading:”))

#b)   Prompt the user to input the ending odometer reading and store it as the variable odoEnd

odoEnd = int(input(“Ending Odometer Reading:”))

#ask user for milage input

print (“(B)udget, (D)aily, or (W)eekly rental?”)

print (“Number of Days Rented”)

print (“Starting Odometer Reading:”)

print (“Ending Odometer Reading:”)

#calulate miles driven

totalMiles = int(odoEnd) – int(odoStart)

#calulating of charges based on miles driven and rental type

if rentalCode == “B” :

     mileCharge = totalMiles*0.25*rentalPeriod

elif rentalCode == “D”:

   averageDayMiles = totalMiles/rentalPeriod

if averageDayMiles <=100 :

  extraMiles = 0

else:

  extraMiles = float(averageDayMiles – 100)

  mileCharge = float(extraMiles*0.25*rentalPeriod)

  averageWeeklyMiles = totalMiles/rentalPeriod

if averageWeeklyMiles <=900:

  extraMiles = 0

else:

 extraMiles = float(totalMiles – 900)

 mileCharge = float(extraMiles*100*rentalPeriod)

amtDue = baseCharge + mileCharge

print (“Rental Summary”)

print(“Rental Code:”+ (”  “) +(rentalCode))

print(“RentalPeriod:” + (”  “) +str(rentalPeriod))

print(“Starting Odometer:” + (”  “) +str(odoStart))

print(“Ending Odometer” + (”  “) + str(odoEnd))

print(“Miles Driven:” + (”  “) +str(totalMiles))

print(“Amount Due:” + (”  $”) +str(amtDue))

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"

account balance

I am trying to get my script to print like this:What would you like to do?

How much would you like to deposit today?

Deposit was $200, current balance is $700.25

but i keep getting an error with my script?import sys

#account balance 

account_balance = float(500.25)

#defines balance

def acc_balance():

#print the beggining balance amount

 print(“Your current balance:n$%.2f”%account_balance)

 return account_balance

#defines deposit

#def deposit_amount():

  #req user to input amt of depsit

userchoice = input(“What would you like to do?n”)      

if userchoice == ‘B’:

  print(“Your current balance:”)

  print (account_balance)

  account_balance = “nBegining Balance: “+str(account_balance)

elif userchoice ==’D’:

 deposit_amount=float(input(“How much would you like to deposit today?n”))

 account_balance = “Deposit Amount: “+str(deposit_amount)

print(“Deposit amount was $%.2f, current balance is $%.2f”%(deposit_amount)

#print(“Your current balance: n%.2f” % account_balance)– if i allow this to run in the script i get File “ATM.py”, line 22

print(“Your current balance: n%.2f” % account_balance)

^

SyntaxError: invalid syntax– i have been trying for hours to get this to work but obviously i am missing something. H E L P please

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"

Initial beginning balance

import sys

#Initial beginning balance

account_balance = float(500.25)

#defines balance

def account_balance():

 #print the beggining balance amount

  print(“Your current balance:n$%.2f”%account_balance)

#defines deposit

def deposit_amount():

#req user to input amt of depsit

 deposit_amount = float(input(“How much would you like to deposit?”))

   # calulated new bal with amt deposited

account_balance = account_balance + deposit_amount**** keeps erroring and i can’t figure out the issue?  account_balance = account_balance + deposit_amount

TypeError: unsupported operand type(s) for +: ‘function’ and ‘function’

Top Answer

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"

account_balance

I can not get the script to print in the correct format of : mine prints the first two line together?

What would you like to do?

Your current balance:

500.25

account_balance = float(500.50)

def balance():

  print(“Your current balance:n$%.2f”%account_balance)

userchoice = input(“What would you like to do?”)           

if userchoice == ‘B’:

 print(“Your current balance:”)

 print (account_balance)

 account_balance = “nBegining Balance: “+str(account_balance)

elif (userchoice == ‘D’):

  deposit_amount=float(input(“How much would you like to deposit today?”))

  deposit(deposit_amount)

  account_balance += “Deposit Amount: “+str(deposit_amount)

elif (userchoice == ‘W’):

  withdrawal_amount=float(input(“How much would you like to withdraw?”))

  withdrawal(withdrawal_amount)

  account_balance += “Withdrawal Amount: “+str(withdrawal_amount)

elif (userchoice == ‘Q’):

  print (“Thank you for banking with us.”)

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"