You are on page 1of 10

num = int(input("Enter a number: "))

sum = 0
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10
if num == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")
num = int(input("Enter a number: "))
factorial = 1
if num < 0:
print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
factorial = factorial*i
print("The factorial of",num,"is",factorial)
fruits = ["apple", "banana", "cherry"]
for x in fruits:
if x == "banana":
break
print(x)
adj = ["red", "big", "tasty"]
fruits = ["apple", "banana", "cherry"]

for x in adj:
for y in fruits:
print(x, y)
for x in range(6):
print(x)
else:
print("Finally finished!")
a = 200
b = 33
c = 500
if a > b and c > a:
print("Both conditions are True")
a = 200
b = 33
c = 500
if a > b or a > c:
print("At least one of the conditions is True")
a = 33
b = 200
if b > a:
print("b is greater than a")
i=1
while i < 6:
print(i)
i += 1
else:
print("i is no longer less than 6")
i = int(input("Enter no."))
while i < 18:
print("i is less than 18")
i += 1

You might also like