Examples of three uses of variables

Assignment Help Business Law and Ethics
Reference no: EM132331845

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;

 else:

   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;

 else:

   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')

Reference no: EM132331845

Questions Cloud

Describe if your topic is being investigated and prosecuted : Describe if your topic is being investigated and prosecuted. Define which levels of government are involved in the investigation and prosecution of this crime.
What role do end users play in incident reporting : What role do end users play in incident reporting? Should end users be encouraged to report suspicious occurrences? Why or why not?
Protect organizational assets against malware : Why is it important to protect organizational assets against malware? What tools other than the ones provided by Microsoft can help fight against malware?
Write your response on a different non-fiction book : The book "New Jack" For this week's discussion post, I would like for you to provide a review of the non-fiction book you read for this class.
Examples of three 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:
Explain the structures of businesses in the arts : A/601/1673-Managing a Creative Business-BH027165 – Edexcel BTEC Levels 4 and 5 Higher Nationals specification in Art and Design- Explain structures of business.
Describe how to simulate a queue using two stacks : Describe how to simulate a queue using two stacks, L and R: Each of the two primary queue operations, enqueue and dequeue, should be implemented by performing
What would be theory and strategy to avoid stereotyping : What would be another theory and strategy to avoid stereotyping individuals in the criminal justice system? Is labeling theory a legitimate crime causation.
Write a nutrition plan : 1 pick a sport to write a nutrition plan. Describe the overall diet that your players/athletes should be using. Describe the overall diet that your players

Reviews

Write a Review

Business Law and Ethics Questions & Answers

  Legal environment of business caselet

The assignment in Law deals with the topic "Legal Environment of Business". A case study about Mary, a newly joined employee who is working in the USA and Europe. She faces few issues at her work place in Europe and tries to talk to her manager who s..

  Business ethics & legal issues caselet

This assignment is about the concept of Business Ethics & Legal Issues. The laws relating to these can be found in Antitrust laws. These laws are concerned with those large corporations which have a majority of market share, mergers and acquisitions.

  Questions on business law and ethics

Examples of securities that are exempted from the registration provisions of the 1933 Act and involving misstatement of material facts in a prospectus.

  Discuss the doctrine of ratification of pre-incorporation

With the aid of a decided cases, discuss the doctrine of ratification of pre-incorporation contract.

  Discuss the extent of phoenixing activity

It has been estimated that about 6,000 phoenix companies operate in Australia, costing government and the community hundreds of millions of dollars per year and impacting on individuals.

  Application of law to facts

Company Law, Application of Law to Facts and Conclusion.

  Question on business law and ethics

This assignment related to business law.

  Questions on business law

Answer all the questions under business law.

  Iidentify the issue raised by the facts

Iidentify the issue(s) raised by the facts, identify the relevant legal principles, apply the relevant legal principles to the facts, reach a conclusion.

  Evaluation of software development

Prepare a report and present an evaluation of the subsequent methodologies for software development in terms of cost, resources and time.

  Business value and ethics

Business value and ethics,  Bart agrees to put Sam's Super Bowl champion-ship autographed football in his sports store to sell for $1,500. Sam agrees to pay Bart a 15% commission for selling the ball. If Joe comes in the sports store and offers Bart ..

  Explain what is meant by income by ordinary concepts

Advise what tax consequences arise in respect of the payments.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd