Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"

uses of variables

In this code I need to “identify examples of three uses of variables in the script using comments in your code.” Specifically, an example of:

  • assigning a numerical or string value to a variable
  • changing variable values
  • modifying values with data-type-appropriate operators, which basically means using things like int().

As well as “Identify examples of the use of branches and explain using comments in your code. Be sure your comments identify the following fundamental statements: if, elif, and else statements.”. Can anyone please help.

import sys

#The user must input the rental code as B, D, or W

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

#Depending on the previous input for the rental code the next lines of code will provide a specific prompt

#to obtain the next input data

if rentalCode == “B”:

 rentalPeriod = input(“Number of Days Rented:n”);

elif rentalCode == “D”:

 rentalPeriod = input(“Number of Days Rented:n”);

elif rentalCode == “W”:

 rentalPeriod = input(“Number of Weeks Rented:n”);

#The variables required to calculate the cost for each type of rental code

budgetCharge = 40.00

dailyCharge = 60.00

weeklyCharge = 190.00 

#This will calculate the cost for each rental cost based on the user input.

if rentalCode == “B”:

 baseCharge = int(rentalPeriod) * float(budgetCharge);

elif rentalCode == “D”:

 baseCharge = int(rentalPeriod) * float(dailyCharge);

elif rentalCode == “W”:

  baseCharge = int(rentalPeriod) * float(weeklyCharge);

#This block will calculate the total miles driven.

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

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

totalMiles = int(odoEnd) – int(odoStart)

#This block states that is the rental code ‘B’ is input, the milage will automatically be calculated.

if rentalCode == “B”:

 mileCharge = float(totalMiles) * 0.25;

#if the rental is a daily then we need to calculate the mileage charge by figuring out the average miles per day    

#once we have the average miles that is then multiplied by a set rate of $0.25 per mile

elif rentalCode == “D”:

 averageDayMiles = float(totalMiles)/float(rentalPeriod);

 if float(averageDayMiles) <= 100:

   extraMiles = 0;


   extraMiles = float(averageDayMiles) – 100;

 mileCharge = (.25 * extraMiles);

#If the rental code is weekly the we need to calculate the mileage charge by again figuring out the average miles per week

#when the average number of weekly miles is greater then or equal to 900 then the mileage charge is zero  i)               Calculate the averageWeekMiles (totalMiles/ rentalPeriod)

#The charge will be $100.00 per week for extra miles if the avarge is more then 900 miles per week.

elif rentalCode == “W”:

 averageWeekMiles = float(totalMiles)/float(rentalPeriod);

 if averageWeekMiles <= 900:

   mileCharge = 0;


   mileCharge = 100 * float(mileCharge)

#By adding the base charge and the milage charge the code will calculate the amount due.

amtDue = float(baseCharge) + float(mileCharge)

#this code will print a receipt for the customer and giving them a summary of all of the charges.

print(“Rental Summary”)

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

print(“Rental Period:  ” + str(rentalPeriod))

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

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

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

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

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