Awael© wK bv wbY©‡qi cvB_b †cÖvMÖvg
year = int(input("Please enter the year:"))
if year == 0:
print("Please! try again")
elif (year%400 == 0 or (year%100!=0 and year%4 == 0)):
print(year,"is a leap year.")
else:
print(year,"is not a leap year.")
Output
Please enter the year:1980
1980 is a leap year.
Please enter the year:2026
2026 is not a leap year.
/////////////////////////////////////////////////////////////////////////////////////////////
we‡Rvo msL¨v wcÖ›U Kivi cvB_b †cÖvMÖvg
for i in range(1, 101):
if (i % 2 != 0):
print(i,end = " ")
Output
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51
53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
‡Rvo/ we‡Rvo msL¨v wcÖ›U Kivi cvB_b †cÖvMÖvg
num= int(input("Please enter your number:"))
if num == 0:
print("Please! try again")
elif num%2!=0:
print("The number is odd")
else:
print("The number is even")
Output
Please enter your number:37
The number is odd
cvk / †dj wbY©q Kivi cvB_b †cÖvMÖvg
mark = int(input('Please enter your mark:'))
if mark >= 40:
print('You have Passed')
if mark < 40:
print('You have Failed')
Output
Please enter your mark:47
You have Passed
////////////////////////////////////////////////////////////////////////////////////////////////
wcivwgW ˆZwi Kivi cvB_b †cÖvMÖvg
for i in range (10) :
for j in range (1, i+1) :
print(j, end = " ")
print()
Output
1
12
123
1234
12345
123456
1234567
12345678
123456789
//////////////////////////////////////////////////////////////////////////////////////////
abvZ¥ / FbvZ¥K msL¨v wbY©q Kivi cvB_b †cÖvMÖvg
num=int(input("Enter the number:"))
if num>0:
print("The number is Positive")
elif num<0:
print("The number is Negative")
else:
print("The number is Zero")
Output
Enter the number:21
The number is Positive
/////////////////////////////////////////////////////////////////////////
‡fvUvi wK bv wbY©q Kivi cvB_b †cÖvMÖvg
age = int (input("Enter your age: "))
if age>=18:
print("You are eligible for voting");
else:
print("Sorry! you are not for voting");
Output
Enter your age: 45
You are eligible for voting
Enter your age: 15
Sorry! you are not for voting
///////////////////////////////////////////////////////////////////
‡hvMdj wbY©q Kivi cvB_b †cÖvMÖvg
sum = 0
i=1
while (i<=100):
sum = sum +i
i = i+1
print(" The summation is:",sum)
Output
The summation is: 5050
bvgZv †kLvi cvB_b †cÖvMÖvg
n=int(input("Enter the number:"))
print("Multiplication table of:",n)
for i in range(1,11):
product=n*i
print(n,"*",i,"=",product)
Output
Enter the number:4
Multiplication table of: 4
4*1=4
4*2=8
4 * 3 = 12
4 * 4 = 16
4 * 5 = 20
4 * 6 = 24
4 * 7 = 28
4 * 8 = 32
4 * 9 = 36
4 * 10 = 40
///////////////////////////////////////////////////////////////////////////////////////////
Used continue to skip printing the value 4
for num in range (1, 11, 1):
if num == 4:
continue
else:
print(num, end=" ")
Output
1 2 3 5 6 7 8 9 10