Python Programming — Conditional Statement

x = float (input ('Enter a number = '));if(x >= 10):
print ('Congratulations, the number you entered is correct')
Enter a number = 11Congratulations, the number you entered is correct
Enter a number = 9#program not executed
x = int(input('enter the value of x: '))
y = int(input('enter the value of y: '))
if x < y:
print('x is less than y')
else:
print('x is more than y')
print('x={}, y={}'.format(x, y))
enter the value of x: 5
enter the value of y: 2
x is more than y
x=5, y=2
enter the value of x: 5
enter the value of y: 5
x is more than y
x=5, y=5
x = int(input('enter the value of x: '))
y = int(input('enter the value of y: '))
if x < y :
print('x is less than y')
elif x > y :
print('x is more than y')
else :
print('x is equal to y')

print('x={}, y={}'.format(x, y))
enter the value of x: 5
enter the value of y: 5
x is equal to y
x=5, y=5
burger_price = 5
money = 20
input_count = input('How many burgers do you want : ')
count = int(input_count)
total_price = burger_price * count
print('You will buy ' + str(count) + ' burgers')
print('Total price is ' + str(total_price) + ' dolars')

if money > total_price:
print('You have bought ' + str(count) + ' burgers')
print('your money is left ' + str(money - total_price) + ' dolar')
elif money == total_price:
print('You have bought ' + str(count) + ' burgers')
print('your wallet is empty')
else:
print('your money is not enough')
print('you cant buy that many burgers')
#if can buy a burgerHow many burgers do you want : 3
You will buy 3 burgers
Total price is 15 dolars
You have bought 3 burgers
your money is left 5 dolar
#if can't buy a burger
How many burgers do you want : 10
You will buy 10 burgers
Total price is 50 dolars
your money is not enough
you cant buy that many burgers

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store