In python 3, how would you do the following?
1. conditional to check if choice is 7. if choice is 7, print out "lucky". if not, print "unlucky"
2. You're provided with a random number in a variable called num. Use a conditional to check if the number is odd. If num is odd, print "odd". If not, print "even" (use modulus % to figure out if number is odd)
Answer 1
Code
choice = int(input("Please enter your choice: ")) # converting
input as integer
if choice == 7:
print("\n\nlucky");
else:
print("\n\nunlucky");
Test Output
Answer 2
Code
num = int(input("Please enter the number: ")) # converting input as
integer
if num%2 != 0:
print("\n\nodd");
else:
print("\n\neven");
Test Output
Get Answers For Free
Most questions answered within 1 hours.