Hey guys, here's the homework for week 2. Solutions will be posted later this week. If you have any problems or questions, be sure to let us know.

Homework:

Write a program that takes two inputs and stores them in the variables feet and inches. Print output of their height in centimeters. (12 inches = 1 foot, 1 inch = 2.54 centimeters)

What do these print?

(“99” - 8) % 6

int(5.8) + float(9) * 3

4 + int(“447”)

str(4) + “447”

str(bool(0)) + “ is the opposite of ” + str(bool(25))

Resources

Class slides: https://docs.google.com/presentation/d/1ZUl6aCzJc6HFCNRWgVy9EiNh8KM2Kw6zqM4VDY8oscc/edit#slide=id.g155f1b6c9e0_0_568

Class code: https://replit.com/@ShravyaS/IntrotoPython-Class2#main.py

Discord: https://discord.gg/28D6hGXP

Contact info:

shravyassathish@gmail.com (mentor)

kingericwu@gmail.com (TA)

felixguo41@gmail.com (TA)

feet = input("length in feet")

inches = 12 * float(feet)

length = float(inches) * 2.54

print("The length is" + " " + str(length) + " " + "centimeters")

Error

32

451

4447

False is the opposite of true

(1.) feet=(input("What's your height in feet?"))

inches=(input("What's your height in inches?"))

combine= ((int(feet)*12+int(inches))*2.54)

print ("You're " + str((combine)) + " in centimeters ")

(2.) (a) error

(b) 32.0

(c) 451

(d) 4447

(e) False is the opposite of true

1.

feet, inches = input("Enter feet and inches: ").split()

centimeters = 2.54 *(int(feet) * 12 + int(inches))

print(f"{feet} feet and {inches} inches = {centimeters} centimeters"

)

2.

a. SyntaxError: invalid character in identifier

b. 32.0

c. 451

d.4447

e. False is the opposite of True

feet = int(input("How tall are you in feet?"))

inches = int(input("How tall are you in inches"))

centimeters = ((feet*12)* 2.54) + (inches * 2.54)

print (f"{feet}ft and {inches}in are equal to {centimeters}centimeters")

(a) Error

(b) 32.0

(c)451

(d)4447

(e) False is the opposite of True

#1 feet = input("Give a positive number (this will be the number of feet): ") inches = input("Give another positive number (this will be the number of inches): ") feet = float(feet) inches = float(inches) centimeters = ((feet * 12) * 2.54) + (inches * 2.54) print(f"{feet} ft and {inches} in are equal to {centimeters} centimeters") #2 Error 32.0 451 4447 False is the opposite of True

feet = int(input("How tall are you in feet? "))

inches = int(input("How many inches tall are you (from the remainder of the previous question) "))

print(f"You are {(12*feet+inches)*2.54} centimeters tall!\n\n" + """Did you know:

- that the python code '("99" - 8) % 6' gives an error statement when printed?

- that the statement 'int(5.8) + float(9) * 3' will print '32.0' in Python shell?

- that 'print(4 + int("447"))' will give '451' when run in Python?

- 'str(4) + "447" will return '4447' if run in Python shell?

- 'str(bool(0)) + " is the opposite of " + str(bool(25))' gives a true statement! False is the opposite of True!""")

print("Please input your height! ")

feet = input("Put in your feet: ")

inch = input("Put in your inches: ")

height = 12*int(feet)+int(inch)

heightFinal = height*2.54

print(f'You are {heightFinal} cm tall!')

a: error

b: 42.0

c: 451

d: 4447

e: False is the opposite of True