11_CS_PRACTICALS
11_CS_PRACTICALS
OUTPUT :
PRACTICAL NO-2
AIM :- Input three numbers and display the largest/smallest number.
num1=int(input("Enter first number : "))
num2=int(input("Enter second number : "))
num3=int(input("Enter third number : "))
if(num1>num2 and num1>num3):
print(num1,"is the largest")
elif(num2>num3 and num2>num1):
print(num2,"is the largest")
elif(num3>num1 and num3>num2):
print(num3,"is the largest")
else:
print("All the three values are equal")
OUTPUT :
PRACTICAL NO-3(a)
AIM :- Generate the following patterns using nested loop.
Pattern-1
*
**
***
****
*****
for i in range(1,6):
for j in range(0,i):
print("*",end='')
print()
OUTPUT :
PRACTICAL NO-3(b)
AIM :- Generate the following patterns using nested loop.
Pattern-2
AIM :- Generate the following patterns using nested loop.
12345
1234
123
12
1
for i in range(5,0,-1):
for j in range(1,i+1):
print(j,end=' ')
print()
OUTPUT :
PRACTICAL NO-4(a)
AIM :- Write a program to input the value of x and n and print the sum
of the following series:
(a) 1 + x + x2 + x3 + x4 + ……. + xn
x=int(input("Enter value of x : "))
n=int(input("Enter value of n : "))
sum=0
for i in range(n+1):
sum += x**i
print("Sum of first ",n,"terms :",sum)
OUTPUT :
PRACTICAL NO-4(b)
AIM :- Write a program to input the value of x and n and print the sum
of the following series:
2 3 4 n
x x x x
(b) x − + − +…
2 3 4 n
OUTPUT :
PRACTICAL NO-5
AIM :- Display the terms of a Fibonacci series.
n=int(input("Enter a number : "))
a=0
b=1
print(a)
print(b)
for i in range(1,n):
c=a+b
a,b=b,c
print(c)
OUTPUT :
PRACTICAL NO-6
AIM :- Count and display the number of vowels, consonants,
uppercase, lowercase characters in string.
string = input("Enter Your String : ")
vowels = consonants = uppercase = lowercase = 0
vowels_list = ['a','e','i','o','u']
for i in string:
if i in vowels_list:
vowels += 1
if i not in vowels_list:
consonants += 1
if i.isupper():
uppercase += 1
if i.islower():
lowercase += 1
print("Number of Vowels in this String = ", vowels)
print("Number of Consonants in this String = ", consonants)
print("Number of Uppercase characters in this String = ", uppercase)
print("Number of Lowercase characters in this String = ", lowercase)
OUTPUT :
PRACTICAL NO-7
AIM :- Input a list/tuple of elements, search for a given element in the
list/tuple.
a=[ ]
size=int(input("Enter the size of the list : "))
for i in range(size):
val=int(input("Enter number : "))
a.append(val)
x=int(input("Enter the element to be searched : "))
count=0
for i in range(0,size):
if a[i]==x:
count=1
break
if(count==1):
print(x," is found at index ",i)
else:
print("Element not found")
OUTPUT :
PRACTICAL NO-8
AIM :- Input a list of numbers and swap elements at the even location
with the elements at the odd location.
a=[ ]
size=int(input("Enter the size of the list : "))
for i in range(size):
val=int(input("Enter number : "))
a.append(val)
print("Original list : ")
for i in range(size):
print(a[i])
s=len(a)
if(s%2!=0):
s=s-1
for i in range(0,size,2):
a[i],a[i+1]=a[i+1],a[i]
print("After Swapping : ",a)
OUTPUT :
PRACTICAL NO-9
AIM :- Create a dictionary with the roll number, name and marks of n
students in a class and display the name of students who have scored
marks above 75.
n = int(input("Enter number of students: "))
result = {}
for i in range(n):
print("Enter Details of student No.", i+1)
rno = int(input("Roll No: "))
name = input("Name: ")
marks = int(input("Marks: "))
result[rno] = [name, marks]
print(result)
# Display names of students who have got marks more than 75
for student in result:
if result[student][1] > 75:
print(result[student][0])
OUTPUT:
PRACTICAL NO-10
OUTPUT :