0% found this document useful (0 votes)
2 views3 pages

Class11 Python Programs Revision

The document provides a revision sheet for Class 11 Computer Science, detailing various Python programs including checking even or odd numbers, finding the largest of three numbers, determining leap years, calculating factorials, generating Fibonacci sequences, summing digits, reversing numbers, checking for palindromes, verifying prime numbers, counting vowels, reversing strings, and performing basic list operations. Each program is presented with its corresponding code snippet. This serves as a practical guide for students to understand and implement fundamental Python programming concepts.

Uploaded by

rishabh2092013
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Class11 Python Programs Revision

The document provides a revision sheet for Class 11 Computer Science, detailing various Python programs including checking even or odd numbers, finding the largest of three numbers, determining leap years, calculating factorials, generating Fibonacci sequences, summing digits, reversing numbers, checking for palindromes, verifying prime numbers, counting vowels, reversing strings, and performing basic list operations. Each program is presented with its corresponding code snippet. This serves as a practical guide for students to understand and implement fundamental Python programming concepts.

Uploaded by

rishabh2092013
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Class 11 Computer Science – Most Expected

Python Programs (Revision Sheet)

Even or Odd
n = int(input("Enter number: "))
if n % 2 == 0:
print("Even")
else:
print("Odd")

Largest of Three
a = int(input("A: "))
b = int(input("B: "))
c = int(input("C: "))

if a >= b and a >= c:


print(a)
elif b >= c:
print(b)
else:
print(c)

Leap Year
year = int(input("Enter year: "))

if (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0):


print("Leap Year")
else:
print("Not Leap Year")

Factorial
n = int(input("Enter number: "))
fact = 1
for i in range(1, n+1):
fact *= i
print(fact)

Fibonacci
n = int(input("Terms: "))
a, b = 0, 1
for i in range(n):
print(a, end=" ")
a, b = b, a + b

Sum of Digits
n = int(input("Enter number: "))
s = 0
while n > 0:
s += n % 10
n //= 10
print(s)

Reverse Number
n = int(input("Enter number: "))
rev = 0
while n > 0:
rev = rev*10 + n%10
n //= 10
print(rev)

Palindrome Number
n = int(input("Enter number: "))
orig = n
rev = 0
while n > 0:
rev = rev*10 + n%10
n //= 10

if orig == rev:
print("Palindrome")
else:
print("Not")

Prime Check
n = int(input("Enter number: "))
prime = True
for i in range(2, n):
if n % i == 0:
prime = False
break

if n > 1 and prime:


print("Prime")
else:
print("Not Prime")

Count Vowels
s = input("Enter string: ").lower()
c = 0
for ch in s:
if ch in "aeiou":
c += 1
print(c)

Reverse String
s = input("Enter string: ")
print(s[::-1])

Palindrome String
s = input("Enter string: ")
if s == s[::-1]:
print("Palindrome")
else:
print("Not")

List Largest
lst = list(map(int, input().split()))
print(max(lst))

List Sum
lst = list(map(int, input().split()))
print(sum(lst))

Simple Calculator
a = int(input())
b = int(input())
op = input()

if op == "+":
print(a+b)
elif op == "-":
print(a-b)
elif op == "*":
print(a*b)
elif op == "/":
print(a/b)

You might also like