PYTHON PROGRAMMING!!! #1 Ask the user to enter a number between 1 and 10 (inclus
ID: 3721312 • Letter: P
Question
PYTHON PROGRAMMING!!!
#1 Ask the user to enter a number between 1 and 10 (inclusive)
num = input('Enter a number.')
if float(num) >= 1 and float(num) <= 10
#2 Ask the user to enter the word 'Number' as shown.
txt = input('Enter the word Number')
#3 Ask the user to enter 'True' or 'False'.
b = input('Enter 'True' or 'False')
#4 If the user entered a number between 1 and 10 (inclusive),
#print 'You satisfied the first condition.'
if float(num) >= 1 and float(num) <=10:
print('You satisifed the first condition')
#5 if the user entered the word 'Number' as shown,
#print 'You satisfied the first condition'
if txt == 'Number':
print('You satisfied the first condition')
#6 if the user satisfied BOTH condition, print
#'You satisfied at least one condition.'
#7 if the user satisfied ONE condition, print
#'you satisfied at least one condition
# 8. If the user entered a number between 1 and 5 (inclusive),
# print 'Your number is between 1 and 5.' Otherwise, print
# 'Your number is NOT between 1 and 5.'
# 9. Use one if, elif, and else clause for this problem.
# If the user entered a value less than 0 (not inclusive),
# print 'Invalid input.' Otherwise, if the number is
# less than 10, print 'Your number is between 0 and 10.'
# Otherwise, print 'Your number is greater than 10.'
# 10. You will need to cast b as a bool() for this problem.
# If the user entered a number NOT equal to 0 and
# also entered 'Number' and also entered a value of
# 'True' for b,
# print 'Comparisons, operators, and block code, oh my!'
Explanation / Answer
PYTHON PROGRAMMING!!!
1
num = input('Enter a number.')
if float(num) >= 1 and float(num) <= 10
2
txt = input('Enter the word Number')
3
b = input('Enter 'True' or 'False')
4
if float(num) >= 1 and float(num) <=10:
print('You satisifed the first condition')
5
if txt == 'Number':
print('You satisfied the first condition')
6)
if (float(num) >= 1 and float(num) <= 10 and txt=="Number"):
print('You satisfied at least one condition.')
7)
if (float(num) >= 1 and float(num) <= 10) or (txt=="Number"):
print('You satisfied at least one condition.')
8)
if num>=1 and num<=5:
print ('Your number is between 1 and 5.')
else:
print ('Your number is NOT between 1 and 5.')
9)
if num<0:
print ('Invalid input')
elif num<10:
print ('Your number is between 0 and 10')
else:
print ('Your number is greater than 10')
10)
if num!=0 and txt=='Number' and bool(b):
print ('Comparisons, operators, and block code, oh my!')
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.