Simple Python Problems

Simple Python Problems Homework Sample

Write a program that accepts an input and returns a different message if the value is negative, positive or zero. Write a program that is for a car rental service for a trip between New York and Washington, assume a price of 25 cents per mile, and the price of petrol per gallon. Write a program that asks the user their name, then asks them a question and produces an answer. Write a program that asks for a grade and displays pass or fail, then asks for a color, for red it displays stop, for green it displays go, and if neither it prints incorrect.


number = int(input(“Enter a number: “))
if (number>0):
print (“Positive”)
print (“Zero”)
print (“Negative”)

D: Find cost of trip from NY to Washington is a rent a car or buying gas cheaper if gas is $3.80 a gallon while the rent car is $100 a day plus $1 each mile? The trip is 227 miles, The Nissan Altima gets 27 miles per gallon:

Divide total miles by miles per gallon which tells you how many gallons of gas is needed: 227/27=8.4
Multiply gallons of gas by the price of the gas per gallon to get the price of gas for one way: 8.4×3.80=38.9
Add $100 a day to the cost of miles for the rent of the car: 227+100=$327
Compare both prices to see which one is better: $38.9 or $327
Choose which one you want to do

distance = 227
gallon_price = 3.8;

nissan_gallons = 227/27
nissan_cost= nissan_gallons*gallon_price

rent_car_cost = distance + 100

print (“Nissan Altima is better”)
print (“Renting a car is better”)

name = input(“Enter your name: “)
last_name = input(“Enter your last name: “)

print (“Hello, “,name,” “,last_name,”. Nice to meet you.”)

print (“How old are you?”)


print (“I knew you were going to answer that.”)

grade=int(input(“Which is your course grade?:”))

colour=input(“Please, select a colour:”)

print (“Pass”)
print (“Fail”)

print (“Go”)
print (“Stop”)
print (“Incorrect”)