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

Class 11 CS Practical Programs Basic NoDef

The document contains a series of basic Python programs for Class 11 Computer Science practicals. It includes programs for checking Armstrong numbers, palindrome strings, creating new strings with uppercase letters or vowels, swapping case, shifting lists, reversing lists, finding occurrences in tuples, generating Fibonacci tuples, and searching keys and values in dictionaries. Each program is presented with its code and a brief description of its functionality.

Uploaded by

Preetham Raaj
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)
9 views3 pages

Class 11 CS Practical Programs Basic NoDef

The document contains a series of basic Python programs for Class 11 Computer Science practicals. It includes programs for checking Armstrong numbers, palindrome strings, creating new strings with uppercase letters or vowels, swapping case, shifting lists, reversing lists, finding occurrences in tuples, generating Fibonacci tuples, and searching keys and values in dictionaries. Each program is presented with its code and a brief description of its functionality.

Uploaded by

Preetham Raaj
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 CS PRACTICAL PROGRAMS (Basic, No def)

1) Armstrong Number
n = int(input("Enter number: "))
temp = n
sum1 = 0
while temp > 0:
d = temp % 10
sum1 = sum1 + d*d*d
temp = temp // 10
if sum1 == n:
print("Armstrong number")
else:
print("Not Armstrong")

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

3) New String with Only Uppercase Letters


s = input("Enter string: ")
new = ""
for ch in s:
if [Link]():
new = new + ch
print("New string:", new)

4) New String with Only Vowels


s = input("Enter string: ")
new = ""
for ch in s:
if ch in "aeiouAEIOU":
new = new + ch
print("New string:", new)

5) Swap Case of Alphabets


s = input("Enter string: ")
new = ""
for ch in s:
if [Link]():
new = new + [Link]()
elif [Link]():
new = new + [Link]()
else:
new = new + ch
print("Swapped case:", new)

6) Right Shift List


L = eval(input("Enter list: "))
last = L[-1]
for i in range(len(L)-1, 0, -1):
L[i] = L[i-1]
L[0] = last
print("Right shifted list:", L)

7) Left Shift List


L = eval(input("Enter list: "))
first = L[0]
for i in range(0, len(L)-1):
L[i] = L[i+1]
L[-1] = first
print("Left shifted list:", L)

8) Reverse List
(i) Without using reverse()
L = eval(input("Enter list: "))
R = []
for i in range(len(L)-1, -1, -1):
[Link](L[i])
print("Reversed list:", R)

(ii) Using reverse()


L = eval(input("Enter list: "))
[Link]()
print("Reversed list:", L)

9) First Occurrence in Tuple


t = eval(input("Enter tuple: "))
x = eval(input("Enter element to find: "))
for i in range(len(t)):
if t[i] == x:
print("First occurrence index:", i)
break
else:
print("Not Found")

10) Fibonacci Tuple (First n terms)


n = int(input("Enter n: "))
a = 0
b = 1
L = []
for i in range(n):
[Link](a)
a, b = b, a + b
t = tuple(L)
print("Fibonacci tuple:", t)

11) Search Key in Dictionary


d = eval(input("Enter dictionary: "))
k = eval(input("Enter key to search: "))
if k in d:
print("Value:", d[k])
else:
print("Not Found")

12) Search Value in Dictionary (Print Key)


d = eval(input("Enter dictionary: "))
v = eval(input("Enter value to search: "))
for k in d:
if d[k] == v:
print("Key:", k)
break
else:
print("Not Found")

You might also like