Python help! I need help getting my code to increment the value. It keep calculating the range over the same number and not moving up! this is the question
Write a program named q1() that prompts the user for the starting and ending distance in Kilometers (km), and an increment value. It should then print the conversion table showing values for Kilometers, Miles (M) and Feet (ft). Each value should be displayed as they are calculated.
and this is the code i have right now
start_km = input("Enter the Starting Kilometers (km): ")
start_km = int(start_km)
end_km = input("Enter Ending Kilometers (km): " )
end_km = int(end_km)
increment = input("Increment value: ")
increment = int(increment)
km = start_km
M = km*(.621371)
ft = M*(5280)
print("km", " ", "M", " ", "ft")
print("==========================")
for i in range(start_km,end_km+1,increment):
print( km, " ", M, " ", ft)
PYTHON CODE:
# getting the starting kilometer
start_km = input("Enter the Starting Kilometers (km): ")
start_km = int(start_km)
# getting the ending kilometer
end_km = input("Enter Ending Kilometers (km): " )
end_km = int(end_km)
# getting the increment
increment = input("Increment value: ")
increment = int(increment)
# printing the table header
print('+' + '-' *62 + '+')
print('|{0:^20}|{1:^20}|{2:^20}|'.format('KM','M','Ft'))
print('+' + '-' *62 + '+')
# loop to convert km to miles, and feet
for i in range(start_km,end_km+1,increment):
miles=i * .621371
feet=i * 3280.84
print('|{0:^20}|{1:^20.2f}|{2:^20.2f}|'.format(i,miles,feet))
print('+' + '-' *62 + '+')
SCREENSHOT FOR OUTPUT:
Python help! I need help getting my code to increment the value. It keep calculating the...
I'm trying to run the code in Python below and keep getting invalid syntax. What's wrong? Thanks for any help! def even(n): if n%2==0 #Enter a Number def main(): n=int(input("Enter a number: ")) #If even print "Number is even" if(even(n)): print("The number is even") #If odd print "Number is odd" else: print("The number is odd") main() #Call the main function
while trying to run this in python, i keep getting the error TypeError: int() can't convert non-string with explicit base. any way to fix this? def binaryToDecimal(n): return int(n,2) if __name__ == '__main__': num3 = int(input("Enter value to be converted: ")) print(binaryToDecimal(num3))
Hey guys, Question with PYTHON I have this simple code and I keep getting 13 for the answer but the answer is actually 13.33. Can someone show me how to get python to return this value! Thanks ! CN = 75 S = (1000/CN) print S
need help with python program The objectives of this lab assignment are as follows: . Input data from user Perform several different calculations Implement conditional logic in loop • Implement logic in functions Output information to user Skills Required To properly complete this assignment, you will need to apply the following skills: . Read string input from the console and convert input to required numeric data-types Understand how to use the Python Modulo Operator Understand the if / elif /...
I need help in Python. This is a two step problem So I have the code down, but I am missing some requirements that I am stuck on. Also, I need help verifying the problem is correct.:) 7. Random Number File Writer Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500. The application should let the user specify how many random numbers the file...
THIS IS THE CODE I AM TRYING TO RUN code # def main(): #Reading a as an integer a = int(input("Enter value for a: ")) #reading b as an interger b = int(input("Enter value for b: ")) #reading n as an integer n = int(input("Enter value for n: ")) # displaying if a and b are congruent modulo n, this is True if a and b #both returns same remainder when divided by n if a % n == b...
Starting out with Python 4th edition I need help with while loops I can't even get one started correctly. Write a program a program that predicts the approximate size of a population of organisms. Problem 4.13 – population Use a while loop; there are no text boxes, just regular input statements Enter number of organisms: 2 Enter average daily increase: 30 Enter number of days to multiply: 10 DAY APPROXIMATE POPULATION ------------------------------------------------- 1 2 2 2.600 3 3.380 4 4.394...
Could anyone help add to my python code? I now need to calculate the mean and median. In this programming assignment you are to extend the program you wrote for Number Stats to determine the median and mode of the numbers read from the file. You are to create a program called numstat2.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The...
PLEASE HELP WITH CODE PYTHON BASE.!!!!!!!! Tasks: Complete the following programs noted below: Problem 1: A painting company has determined that for 112 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $35.00 per hour for labor. Write a program that asks the user to enter the square feet of wall space to be painted and the price of paint per gallon. The program should display the following data:...
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":...