Homework:
Write a program that takes two inputs and stores them in 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/1-N_NI0x7VWJPifcFJ5MhrdIM52iFB9Fq0ttRNVl9_YM/edit?usp=sharing VERY IMPORTANT YOU LOOK THROUGH THIS, IMPORTANT INFORMATION REGARDING CONTESTS!!
Class Code: main.py - Python-Week1Day2 - Replit
Contact info:
shravyassathish@gmail.com (mentor)
Make sure to "Add a comment" with your code to the homework in order to submit your homework assignment!
Recordings for class #2 have been sent out through email :)
#1)
feet = int(input("Type your height in feet: "))
inches = int(input("Type your height in inches: "))
cmFTHeight = feet * 30.48
cmINHeight = inches * 2.54
print("Your height in centimeters is " + cmFTHeight + " your height in inches is " + cmINHeight)
#2)
error
32.0
451
4447
False is the opposite of true
feet = int(input("type a number for ft: "))
inches = int(input("type a number for in: "))
ftCM = feet * 30.48
inCM = 2.54 * inch
print(f'Your input of feet in cm is: {ftCM} and your input of inches to cm is: {inCM}')
error
32.0
451
4447
False is the opposite of true
HI = input("Enter a number (feet->inches):")
BYE = input("Enter different number (inches->centimeters)")
HI = float(HI)* 12
BYE = float(BYE)* 2.54
print("The first number in inches is " + str(HI) + ".")
print("The second number in centimeters is " + str(BYE) + ".")
- Invalid because strings can't minus integer
- 32.0
- 451
- 4447
- False is the opposite of true
# 1. one = input("Enter a number (ft -> in): ") two = input("Enter another number (in -> cm): ") one = float(one) * 12 two = float(two) * 2.54 print("The first number in inches is " + str(one) + ".") print("The second number in centimeters is " + str(two) + ".") # 2. # 1. an error # 2. float(32.0) # 3. int(451) # 4. "4447" # 5. "False is the opposite of True"
Ernie
1.
Height = input("What is your height(inches)? \n") Height2 = input("What is your height(feet with decimals)? \n") h2 = (float(Height) * 2.54) print(f'Your height in centimeters is {h2} cm.' )
2. a. error, can't do operations with a string and an integer
b. 32
c. 451
d. "4447"
e. "False is the opposite of True"
3. a. +
b. + or - or *
feet = input('Enter the number of feet/foot.') feet = int(feet) inches = 12 print((str(feet * inches)) + f' inches is equal to {feet} feet.') cm = 2.54 print(str(feet * inches * cm) + ' centimeters is equal to ' + (str(feet * inches)) + ' inches.')
• invalid (str can't minus the int)
• 32.0
• 451
• 4447
• False is the opposite of true