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 am working on this switch statement code and I am getting errors. Please help. import java.util.Scanner; public class Switchstatement { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here } class Convertor { public static void main(String[] args) { int choice; Double Yen, UsDollars, Kilometer, Miles, Kilograms, Pounds, Inches; Double Centimeters, result; Scanner scanner = new Scanner(System.in); System.out.print("Enter 1\t UsDollars to Yen:...
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...
Please answer this question as if you have NO coding experience. Develop a Python application that incorporates using appropriate data types and provides program output in a logical manner. Your program should prompt a user to enter a car brand, model, year, starting odometer reading, an ending odometer reading, and the estimated miles per gallon consumed by the vehicle. Store your data in a dictionary and print out the contents of the dictionary. I'm this far but cannot get it...
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...
Chapter 08 Python Assignment: Question 1-5 Please I need help in my python course. Question 1 The finally clause of a try statement a. can be used to recover from an exception b. is required c. can be used to display more information about an exception d. is executed whether or not an exception has been thrown 10 points Question 2 Which of the following is the correct way to code a try statement that catches any type of exception...