Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
15 views

Class 11_CS_Practicals_Python Programming-1

All about python

Uploaded by

Pratibha jain
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Class 11_CS_Practicals_Python Programming-1

All about python

Uploaded by

Pratibha jain
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

TABLE OF CONTENTS

Sr No Assignment Page No Submission Teacher’s


Date Sign
1 Write a program to calculate Simple 2/08/2024
Interest.
2 Write a program to check whether the 9/08/2024
number is Even or Odd.
3 Write a program to check whether year is a 9/08/2024
Leap year or not.
4 Write a program to generate a report card. 30/08/2024

5 Write a program to print those number 30/08/2024


which are divisible by 5 up to 100.

6 Write a program to calculate and print 30/08/2024


factorial of a number.
7 Write a program to determine whether a 30/08/2024
number is a perfect number or not.
8 Write a program to determine whether a 27/09/2024
number is a Armstrong number or not
9 Write a program to determine whether a 27/09/2024
number is a palindrome number or not.
10 Write a program to determine whether a 27/09/2024
number is a prime number or composite.
11 Write a program to convert decimal number 27/09/2024
into its binary equivalent.
12 Write a program to display the terms of a 27/09/2024
Fibonacci series up to n.

13 Write a program to print LCM of two 27/09/2024


number.
14 Write a program to print the pattern. 27/09/2024

15 Write a program to reverse a string using 18/10/2024


slicing.
16 Write a program to count and display the 25/10/2024
number of vowels, consonants, uppercase,
lowercase characters in string.
17 Write a program to input a string and 25/10/2024
determine whether it is a palindrome or not.
18 Write a program to find the largest/smallest 22/11/2024
number in a list/tuple.
19 Write a program to input a list of numbers 22/11/2024
and swap elements at the even location with
the elements at the odd location.

1|Page
20 Input a list/tuple of elements, search for a 22/11/2024
given element in the list/tuple.
21 Write a program to create a dictionary with 3/01/2025
the roll number, name and marks of n
students in a class and display the names of
students who have marks above 75.

2|Page
Practical No-1

# Write a program to calculate Simple Interest

Source Code

p = int(input('Enter principal : '))


r = int(input('Enter rate of interest : ') )
t = int(input('Enter time period is :'))
si = (p * r * t)/100
print('The Simple Interest is', si)

Output

3|Page
Practical No-2

#Write a program to check whether the number is Even or Odd.

Source Code

num = int(input("Enter a number: "))


if (num % 2) == 0:
print("{0} is Even".format(num))
else:
print("{0} is Odd".format(num))

Output

4|Page
Practical No-3
# Write a program to check whether year is a Leap year or not.

Source Code

year = int(input('Enter the year :'))

if (year % 400 == 0) and (year % 100 == 0):


print("{0} is a leap year".format(year))
elif (year % 4 ==0) and (year % 100 != 0):
print("{0} is a leap year".format(year))
else:
print("{0} is not a leap year".format(year))

Output

5|Page
Practical No-4

# Write a program to generate a report card.

Source Code

student_number=int(input("enter the serial number of student - "))


student_name=input("enter the name of the student -")
roll_no=input("enter the student roll number -")
class_number=input("enter the class of the student -")
print("student name is -",student_name)
print("roll number is -",roll_no)
print("student class -",class_number)
M=float(input("enter the maths marks ="))
print("maths marks are conducted for 100")
S=float(input("enter the science marks ="))
print("science marks are conducted for 100")
P=float(input("enter the IT marks ="))
print("IT marks are conducted for 100")
H=float(input("enter the hindi marks ="))
print("hindi marks are conducted for 100")
E=float(input("enter the english marks ="))
print("english marks are conducted for 100")
K=(M+S+P+H+E)
print("total marks obtained by the student is -",K)
print("Total marks are conducted for exam is - 500")
Q=K/5
print("Average of the student is -",Q)
if Q>90 and Q<=100:
print("congratualtions your Grade is A")
elif Q>80 and Q<=90:
print("good your grade is B")
elif Q>70 and Q<=80:
print("keep it up Your grade is c")
elif Q>60 and Q <=70:
print("not bad get higher and your grade is D")
else:
print("sorry you are failed")
print("Thanking you hope you will get good marks")

6|Page
Output

7|Page
Practical No-5

# Write a program to print those number which are divisible by 5 upto


100.

Source Code

for num in range(1,101):


if num % 5 == 0:
print(num,end='\t')

Output

8|Page
Practical No-6

# Write a program to calculate and print factorial of a number.

Source Code

num = int(input("Enter a number: "))


factorial = 1
if num < 0:
print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
factorial = factorial*i
print("The factorial of",num,"is",factorial)

Output

9|Page
Practical No-7

# Write a program to determine whether a number is a


perfect number or not.

Source Code

n = int(input("Enter any number: "))


sum1 = 0
for i in range(1, n):
if(n % i == 0):
sum1 = sum1 + i
if (sum1 == n):
print("The number is a Perfect number!")
else:
print("The number is not a Perfect number!")

Output

10 | P a g e
Practical No-8

# Write a program to determine whether a number is a


Armstrong number or not
Source Code

num = int(input("Enter a number: "))


sum = 0
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10

if num == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")

Output

11 | P a g e
Practical No-9

# Write a program to determine whether a number is a


palindrome number or not.

Source Code

N = int(input('Enter the number : '))


rev = 0
oN = N
rem = 0
while N > 0:
rem = N % 10
rev = rev * 10 + rem
N //= 10

if rev == oN:
print("The number is a palindrome")
else:
print("The number is not a palindrome")

Output

12 | P a g e
Practical No-10

# Write a program to determine whether a number is a prime


number or composite.

Source Code

num = int(input("Enter a number: "))


flag = False
if num == 1:
print(num, "is not a prime number")
elif num > 1:
for i in range(2, num):
if (num % i) == 0:
flag = True
break
if flag:
print(num, "is not a prime number")
else:
print(num, "is a prime number")

Output

13 | P a g e
Practical No-11

# Write a program to convert decimal number into its binary


equivalent.

Source Code

num = int(input('Enter the number : '))


binaryArray = []
while num>0:
binaryArray.append(num%2)
num = num//2
for j in binaryArray[: : -1]:
print(j, end="")

Output

14 | P a g e
Practical No-12

# Write a program to display the terms of a Fibonacci series


upto n.
Source Code

nterms = int(input("How many terms? "))

# first two terms


n1, n2 = 0, 1
count = 0

# check if the number of terms is valid


if nterms <= 0:
print("Please enter a positive integer")
# if there is only one term, return n1
elif nterms == 1:
print("Fibonacci sequence upto",nterms,":")
print(n1)
# generate fibonacci sequence
else:
print("Fibonacci sequence:")
while count < nterms:
print(n1)
nth = n1 + n2
# update values
n1 = n2
n2 = nth
count += 1

Output

15 | P a g e
Practical No-13

# Write a program to print LCM of two number.


Source Code

x = int(input('Enter the first number : '))


y = int(input('Enter the second number : '))
if x > y:
greater = x
else:
greater = y

while True:
if((greater % x == 0) and (greater % y == 0)):
lcm = greater
break
greater += 1

print("The L.C.M. is", lcm)

Output

16 | P a g e
Practical No-14

# Write a program to print the pattern


12 +22 +32 + 42 +… +n2

Source Code

n = int(input('Enter the value of n :'))


sum=0
for i in range(1,n+1):
sum += i**2
print(sum)

Output

17 | P a g e
Practical No-15

# Write a program to reverse a string using slicing.

Source Code

str = input("Enter the string : ")


print(str[::-1])

Output

18 | P a g e
Practical No-16

# Write a program to count and display the number of vowels,


consonants, uppercase, lowercase characters in string.

Source Code

str = input("Enter the string : ")


count_vowel =0
count_cons =0
count_upper =0
count_lower =0

for i in str:
if i.islower():
count_lower+=1
if i.isupper():
count_upper+=1
if i in 'aeiouAEIOU':
count_vowel+=1
else:
count_cons+=1
print("Total count of vowels : ",count_vowel)
print("Total count of consonants : ",count_cons)
print("Total count of uppercase characters : ",count_upper)
print("Total count of lowercase characters : ",count_lower)

Output

19 | P a g e
Practical No-17

# Write a program to input a string and determine whether it


is a palindrome or not.

Source Code

str = input("Enter the string : ")


w = ""
for i in str[::-1]:
w=w+i
if str == w:
print(str, " is Palindrome")
else:
print(str, " is not Palindrome")

Output

20 | P a g e
Practical No-18

# Write a program to find the largest/smallest number in a


list/tuple.

Source Code

lst = []
num = int(input('How many numbers: '))
for i in range(num):
num = int(input('Enter number : '))
lst.append(num)
print("Maximum element in the list is :", max(lst), "\nMinimum element in the list is
:", min(lst))

Output

21 | P a g e
Practical No-19

# Write a program to input a list of numbers and swap


elements at the even location with the elements at the odd
location.

Source Code

val=eval(input("Enter a list "))


print("Original List is:",val)
s=len(val)
for i in range(0,s,2):
val[i],val[i+1]=val[i+1],val[i]
print("List after swapping :",val)

Output

22 | P a g e
Practical No-20

# Input a list/tuple of elements, search for a given element in


the list/tuple.

Source Code

list1 =eval(input("Enter a list "))


num = int(input("Enter the element to search : "))
found = False
for i in range(len(list1)):
if list1[i] == num:
print("Element found at the inxex :",i)
found = True
break
if found == False:
print("Element does not exist...")

Output

23 | P a g e
Practical No-21

# Write a program to create a dictionary with the roll number,


name and marks of n students in a class and display the
names of students who have marks above 75.

Source Code

n = int(input("Enter number of students: "))


result = {}
for i in range(n):
roll_no = int(input("Roll No: "))
std_name = input("Student Name: ")
marks = int(input("Marks: "))
result[roll_no] = [std_name, marks]

print(result)

# Display names of students who have got marks more than 75


for i in result:
if result[i][1] > 75:
print("Student's name who get more than 75 marks is/are",(result[i][0]))

Output

24 | P a g e

You might also like