0 ratings0% found this document useful (0 votes) 6 views4 pagesPython Lab.2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
Input & ovdpat
Enter year} 2025
Ps
Contro. Statement ?—
Ree ea ET
4. Check a given year ig leap year or not:
Program’
yeor = int (input (“Enter year? *)) |
if (Year 44220) and (year 7 100 !=9) OF (year 4 400==0):
pint (yer, “ig leap yar)
else :
pant (year, “is not 2 leap yer")
2025 is wot a leap year
® Eder yew : 2020 a
2020 is leap year
2 Check whether a character is alphabet , digit or special character.
Proggasn:-
ch = input (“Eten duvacter: *)
% = ord (ch) . ‘ |
€ («2299 ond KEIRA of K>=65 ad x<=90)?
print (“ab is 0
elif (e>=48 ond
print (ATE
else: J
print (*
Anput_ & oubpult=
( Bter a character +
“i .
7 aly is a Special
character3% Find Ged of 0 numbers.
eoren=
Frograr
asb= ap (int, tnpit(KEnler tuo numlen? "split O)
x = min (a,b)
for i in range (4, 44): |
i€ (a%izco ond b*i =a)! |
ade i
pred (Geo of fat ard Goh +", ged) |
Sopat_& Oulputs
Evter two number!
Geo of 36 and 4B ist IR
Bb 4B
4. Check whether a given number iS an armstrong amber
ov not -
Peogram'= ,
Sean ane al Gepate (Gen aaeen se)
order = len (ste (num)
suum = 0
temp = num
while (temp >0):
digit = temp 7 (0
sum += digit * 7 order
temp = 40
if (um = = Sum):|5- Rant ‘he prime numbers byfween 1 te 409.
Georpam-
pent (Pome numbers befween 1 to 100: )
for n in wange (a, 101):
flog = True
for 1 in range Qn):
if (wei = Ne
flag = False
break
i€ flag == True!
prt (m,end= * “)
Peime rumber betieen 4 tv (6! _
Dns Sica emiSie Mien (3705) um2 ues! cr 4 4%
so 61 67 Fl 73 7 33 89 oT
| Bearer =
| sum =0 |
mee oulpst:-
b= 4 5
c=0 3
34
while (¢<= 4000): ies
ee 610
| a,b = b,c teen
ane = 1): Bee ae
print (4)
Sum = sum +e
print (“Sims *, sum)
6. Colewate the sum of even Fibonacci numbers jf 4 thousand2. Frint the Allowing patterns:
y 4 ) * i) xe F *
te Ft Se x 4%
ee ee ORK * *
Begreon'- () ‘i
fon 1 im range (4444)?
pint (He # pends ‘Nw!) One spse after stor
*
x *
* F ®
Peegeomn ‘= ®
for ot im range (4, 344)?
pe (Ma Gi) + oe? * Gti -4) end = “\n")
# Thee spaces and before -alter one me
exon: ©)
for i my Yonge (4,0, ~
pant Cog (4
4 Two spaces ond,
*
*~ *
*
* KE