Code comments explain and facilitate navigation of the code
python
import sys
rentalcode = input("(B)udget, (D)aily, or (W)eekly rental?\n").upper()
if rentalcode == 'B' or rentalcode == 'D':
rentalperiod = int(input("Number of Days Rented:\n"))
else:
rentalperiod = int(input("Number of Weeks Rented:\n"))
# Pricing
budget_charge = 40.00
daily_charge = 60.00
weekly_charge = 190.00
#Second Section 2
odostart =int(input("Starting Odometer Reading:\n"))
odoend =int(input("Ending Odometer Reading:\n"))
totalmiles = int(odoend) - int(odostart)
if rentalcode == 'B':
milecharge = 0.25 * totalmiles
if rentalcode == "D":
averagedailymiles = int(totalmiles) /int(rentalperiod)
if averagedailymiles <= 100:
totalmiles = 0
elif averagedailymiles > 100:
extramiles = averagedailymiles - 100
milecharge = .25 * extramiles
if rentalcode == "W" and averagedailymiles > 900:
milecharge = rentalperiod * 100
elif rentalcode == "W" and averagedailymiles <= 900:
milecharge = 0
if rentalcode == "B":
basecharge = rentalperiod * budget_charge
elif rentalcode == "D":
basecharge = rentalperiod * daily_charge
elif rentalcode == "W":
basecharge = rentalperiod * weekly_charge
amtdue = float(basecharge) +float(milecharge)
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:"+"${:,.2f}".format(amtdue))Dear Student ,
As per requirement submitted above kindly find below solution.
Here new python program with name "rental.py" is created which contains below code.
rental.py:
import sys #import module
#asking user rental ,upper() function in python used to convert
user input to upper case
rentalcode = input("(B)udget, (D)aily, or (W)eekly
rental?\n").upper()
if rentalcode == 'B' or rentalcode == 'D': #cheking rental code
using if statemnet
#if rental code is B then asking user rented days
rentalperiod = int(input("Number of Days Rented:\n"))
else:
#If rented code is either D or W then asking user weeks
rented
rentalperiod = int(input("Number of Weeks Rented:\n"))
# declaring variable to set Pricing
budget_charge = 40.00 #this variable store budget charge
daily_charge = 60.00 #this variable store daly charge
weekly_charge = 190.00 #this variable store weekly charge
#Second Section 2
odostart =int(input("Starting Odometer Reading:\n")) #asking user
starting odometer reading
odoend =int(input("Ending Odometer Reading:\n")) #asking user
ending odometer reading
#total miles can be found by subtraction odometerending reading
from starting reading
totalmiles = int(odoend) - int(odostart)
#checking rentalCode
extramiles=0 #declaring variable
if rentalcode == 'B':#if rentalCode is B then calculate mile
charge
milecharge = 0.25 * totalmiles
if rentalcode == "D": #if rentalCode is D then
averagedailymiles = int(totalmiles) /int(rentalperiod) #cakculate
daily average miles
if averagedailymiles <= 100: #checking averagedailymiles
totalmiles = 0 #if averagedailymiles is less than or equal to 100
then set totalmiles
elif averagedailymiles > 100: #if averagedailymiles is greater
than 100 then
extramiles = averagedailymiles - 100 #calculate extramiles
milecharge = .25 * extramiles #calculate mile charge
if rentalcode == "W" and averagedailymiles > 900: #checking
rentalCode and averagedailymiles
milecharge = rentalperiod * 100 #if renatlCode=W and
averagedailymiles is gretaer than 900 then calculate mile
charge
elif rentalcode == "W" and averagedailymiles <= 900:
milecharge = 0 #if rentalCode is W and averagedailymiles is less
than or equal to 0 then calculate mile charge
if rentalcode == "B":#if rentalCode is B then
basecharge = rentalperiod * budget_charge #calculate
baseCharge
elif rentalcode == "D":#if rentalCode is D then
basecharge = rentalperiod * daily_charge #calculate
baseCharge
elif rentalcode == "W": #if rentalCode is W then
basecharge = rentalperiod * weekly_charge #calculate
baseCharge
amtdue = float(basecharge) +float(milecharge) #calculate amount
due
print("Rental Summary") #print rental summary details
print("Rental Code:" + str(rentalcode)) #print rental code
print("Rental Period:" + str(rentalperiod)) #print rental
period
print("Starting Odometer:" + str(odostart)) #print start odometer
reading
print("Ending Odometer:" + str(odoend))#print end odometer
reading
print("Miles Driven:" + str(totalmiles))#print total miles
print("Amount Due:"+"${:,.2f}".format(amtdue)) #print amount
due
***********************************
Screen for indentation :


==================================
Output :Compile and run rental.py to get the screen as shown below
Screen 1:rental.py , screen for couple of runs

NOTE :PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.
Code comments explain and facilitate navigation of the code python import sys rentalcode = input("(B)udget, (D)aily,...
Section 1: Collect customer input ''' rentalCode = input('(B)udget, (D)aily, or (W)eekly rental?\n') if rentalCode == 'B' or rentalCode == 'D': rentalPeriod = int(input('Number of Days Rented:\n')) else: rentalPeriod = int(input('Number of Weeks Rented:\n')) daysRented = rentalPeriod #Assigning a dollar amount (double floating number) to the varying rates budget_charge = 40.00 daily_charge = 60.00 weekly_charge = 190.00 #baseCharge changes value based on the type of rental code using multiplication #Each branch of if or elif assignes a different value to...
I am completing a rental car project in python. I am having syntax errors returned. currently on line 47 of my code "averageDayMiles = totalMiles/daysRented" my entire code is as follows: #input variable rentalCode = input("(B)udget , (D)aily , (W)eekly rental? \n") if(rentalCode == "B"): rentalPeriod = int(input("Number of hours rented?\n")) if(rentalCode == "D"): rentalPeriod = int(input("Number of days rented?\n")) if(rentalCode == "W"): rentalPeriod = int(input("Number of weeks rented?\n")) rentalPeriod = daysRented return rentalCode , rentalPeriod budget_charge = 40.00 daily_charge...
what am I missing? this should be the output: (B)udget, (D)aily, or (W)eekly rental? B Starting Odometer Reading: Ending Odometer Reading: 1234 2222 988 247.00 my output is this: (B)udget, (D)aily, or (W)eekly rental? Starting Odometer Reading: Ending Odometer Reading: 1234 2222 988 247.00 here's my code so far: import sys ''' Section 1: Collect customer input ''' #Add customer input 1 here, rentalCode = input("(B)udget, (D)aily, or (W)eekly rental?") #Collect Customer Data - Part 2 #4)Collect Mileage information: ##a)...
BELOW CODE DONE IN CODIO AND PASSED THE FIRST SET OF CHECKS FOR COLLECT CUSTOMER DATA PART 2 (CODIO) CHECK INSTRUCTIONS BELOW - PASSED Collect Customer Data - Part 2 Collect Mileage information: Prompt: "Starting Odometer Reading:\n" Variable: odoStart = ? Prompt: "Ending Odometer Reading:\n" Variable: odoEnd = ? Add code to PRINT odoStart and odoEnd variables as well as the totalMiles to check your work. The following data will be used as input in the test: odoStart = 1234...
Collect Customer Data - Part 1 Hint: This input code is similar to the code in the previous step but use a conditional statement to test if the rentalPeriod is a daily or weekly rental then set the user input equal to rentalPeriod. Add code to PRINT the rentalCode and rentalPeriodvariables to check your work. The following data will be used as input in the first check: rentalCode = 'D' rentalPeriod = 5 Customer Data Check 1A Check It!SHOW DIFF...
Calculate the base charge if rentalCode == 'B': baseCharge = rentalPeriod * budgetCharge Set the base charge for the rental type equal to the variable baseCharge. The base charge is the rental period * the appropriate rate: For example: Finish the conditional statement by adding the conditions for other rental codes. import sys ''' Section 1: Collect customer input ''' # For holding cost of miles drive mileCharge = 0 # Reading type of rental rentalCode = input("(B)udget, (D)aily, or...
Propose: In this lab, you will complete a Python program with one partner. This lab will help you with the practice modularizing a Python program. Instructions (Ask for guidance if necessary): To speed up the process, follow these steps. Download the ###_###lastnamelab4.py onto your desktop (use your class codes for ### and your last name) Launch Pyscripter and open the .py file from within Pyscripter. The code is already included in a form without any functions. Look it over carefully....
Here is my code for minesweeper in python and it has something
wrong. Could you please help me to fix it?
import tkinter as tk
import random
class Minesweeper:
def __init__(self):
self.main = tk.Tk()
self.main.title("mine sweeper")
self.define_widgets()
self.mines = random.sample( [(i,j) for i in range(25) for j in
range(50) ],self.CustomizeNumberOfMines())
print(self.mines)
self.main.mainloop()
self.CustomizeNumberOfMines()
def define_widgets(self):
""" Define a canvas object, populate it with squares and
possible texts """
self.canvas = tk.Canvas(self.main, width = 1002, height=502,
bg="#f0f0f0")
self.canvas.grid(row=0, column=0)
self.boxes =...