Input Problems

Problem 1

print("Problem 1")

Write a program that asks the user to enter their name. Print a message that says hello to the user using his or her name.

Problem 2

print("Problem 2")

Write a program that asks, "What is your favorite color?". Assign the input to the variable named color. Print the following statement, "My favorite color is ____" where ____ is the value of the variable color.

Problem 3

print("Problem 3")

Write Python code that asks, "What town do you live in?". Assign the input to the variable named town. Print the following statement, "I live in ____" where ____ is the value of the variable town.

Problem 4

print("Problem 4")

Write Python code that asks, "How many brothers do you have?". Assign the input to the variable named brothers.

Print the following statement, "I have ____ brothers." where ____ is the value of the variable brothers.

Next, ask, "How many sisters do you have?". Assign the input to the variable named sisters.

Print the following statement, "I have ____ sisters." where ____ is the value of the variable sisters.

Assign the variable siblings to the sum of brothers and sisters.

Print the following statement, "I have ____ siblings."

Problem 5

print("Problem 5")

Write a program that asks the user to enter the length and width of a room.

Assign the variable area according to the formula:

Area=lwArea = lw

Assign the variable perimeter according to the formula:

Perimeter=2l+2wPerimeter=2l+2w

Print the following statement, "The area of the rectangle is ____" where ____ is the area of the rectangle .

Print the following statement, "The perimeter of the rectangle is ____" where ____ is the perimeter of the rectangle.

Problem 6

print("Problem 6")

Write Python code that asks, "What is the side of a square". Assign the input to the variable side.

Assign the variable area according to the formula:

Area=s2Area=s^2

Assign the variable perimeter according to the formula.

Perimeter=4sPerimeter=4s

Print the following statement, "The area of the square is ____" where ____ is the area of the square.

Print the following statement, "The perimeter of the square is ____" where ____ is the perimeter of the square.

Problem 7

print("Problem 7")

Write a program that asks the user how many feet and how many inches they are. Compute and print the equivalent number in centimeters.

One foot is 12 inches. One inch is 2.54 centimeters.

Problem 8

print("Problem 8")

Previously, you wrote a program that calculated the area of a square. It is also possible to calculate the area of a triangle when all three sides are known. Ask the user for s1, s2, s3. Let

s=s1+s2+s32s=\frac{s1+s2+s3}{2}

The area of a triangle can be calculated using the formula

area=s(ss1)(ss2)(ss3)area=\sqrt{s (s-s1)(s-s2)(s-s3)}

Print the area.

Problem 9

print("Problem 9")

Ask the user for the number of days, hour, minutes and seconds. Calculate the duration of time in seconds.

Print the total number of seconds in the duration.

Problem 10

print("Problem 10")

You plan on getting a summer job at the end of the school year.

Write Python code that asks, “How much will you make per hour?” Assign the input to the variable rate. Then ask, “How many hours will you work per week?”. Assign the input to the variable hours.

Assign the variable money to the amount of money you’ll make. What's the formula?

What's the formula?

Print the following statement, “If I work, I’ll make ____.” where ____ is the amount of money.

Problem 11

print("Problem 11")

Write Python code that asks, "How much data did you use this month in gigs". Assign the input to the variable gigs. Your phone company charges $15 for talk and text and $5 per gig.

Assign the variable total to the total amount of money you’ll owe this month.

What's the formula?

Print the following statement, "This month I will owe ____".

Problem 12

print("Problem 12")

Write Python code that asks, "What is the temperature in Fahrenheit". Assign the input to the variable F.

Assign the variable celsius according to the formula:

celcius=59(F32)celcius=\frac{5}{9} (F-32)

Print the following statement, "The temperature in Celsius is ____."

Problem 13

print("Problem 13")

Write Python code that asks, "What is the temperature in Celsius". Assign the input to the variable C.

Assign the variable Fahrenheit according to the formula:

fahrenheit=95C+32fahrenheit = \frac{9}{5}C + 32

Print the following statement, "The temperature in Fahrenheit is ____."

Problem 14

print("Problem 14")

Write a program that asks for the length and width of a farmer's field in feet.

There are 43,560 square feet in an acre.

Print the area of the field in acres.

Problem 15

print("Problem 15")

Write a program that calculates how much the total bill at restaurant including tax and tip. Ask the user the price of their appetizer, entree and dessert. Calculate the tip as 18% of the meal amount. New Jersey sales tax is currently 6.625%

To convert % to a decimal, divide by 100. For example 18% = .18

Print the following:

  • Subtotal (Appetizer, Entree and Dessert)

  • Tax

  • Tip

  • Grand Total (Subtotal, Tax, Tip)

Problem 16

print("Problem 16")

At Kean, the part-time (less than 12 credits) per credit rate is $389.00 plus $91.25 in mandatory fees. Ask the user how many credits they are taking this semester (assume less than 12). Print how much their tuition bill is.

Problem 17

print("Problem 17")

Ask the user the total range of their car and the tank size in gallons. MPG is calculated as total range divided by tank size.

Print the MPG or miles per gallon of their car.

Problem 18

print("Problem 18 - Simple Interest")

Write a program that calculates the accrued amount that includes principal and interest. Ask the user for the Principal, rate and time.

A=P(1+rt)A=P(1+rt)
  • A = Total Accrued Amount (principal + interest)

  • Principal = Principal Amount

  • r = Rate of Interest per year in decimal

  • t = Time Period involved in years

Example annual percentage interest rates. To convert % to decimal, divide by 100.

Print the total accrued amount.

Problem 19

print("Problem 19 - Compound Interest")

Write a program that calculates compound interest on an investment or savings.

A=P(1+rn)ntA=P(1 + \frac{r}{n})^{nt}
  • A = Accrued Amount (principal + interest)

  • P = Principal Amount

  • r = Annual Nominal Interest Rate as a decimal

  • t = Time Involved in years

  • n = number of compounding periods

Example annual percentage interest rates. To convert % to decimal, divide by 100. Assume quarterly compounding.

Print the total accrued amount.

Problem 20

print("Problem 20 - Credit Card Interest")

To calculate how much interest you’ll be charged on your credit card, you’ll need to know your average daily balance, the number of days in your billing cycle and your APR.

interest=r365(amount)(days)interest =\frac{r}{365}(amount)(days)
  • r = Annual Nominal Interest Rate as a decimal

  • amount = average amount you owe

  • days = days in billing cycle

Example annual percentage interest rates. To convert % to decimal, divide by 100.

Print the amount of interest on your monthly bill.