0% found this document useful (0 votes)
26 views35 pages

Practical File Computer Science 11

Uploaded by

Jaspreet Kaur
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)
26 views35 pages

Practical File Computer Science 11

Uploaded by

Jaspreet Kaur
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
You are on page 1/ 35

Tagore International Sen. Sec.

School

A Practical File

Computer Science

Session 2024-25

Submitter by: Submitted to:

Name: Department of Computer Science

Class:

Stream: Teacher’s Signature

Roll No:
Certificate

This is to certify that …………………………………………student of

XI Science/Commerce/Arts has successfully completed the practical file

of Computer Science for the session 2024-25.

Internal Examiner Principal


Index

Sr. No. Title Teacher Signature


1 Addition of Two Number

2 Print table of 2
3 Print cube from 1 to 10
4 Print series 1, 4, 7, 10, 13, 17
5 Print series 1, 4, 7, 10, 13, 16…..
6 Calculate the area of rectangle
7 Check whether number is even or odd
8 Write a program of basic calculator
9 Write a program to check if number is
positive or negative
10 Write a program to print 1 to 10
11 Write a program to print 6 to 10 from
range 1 to 10
12 Write a program to print 1 to 5 from
range 1 to 10
13 Write a program to print 5 from range
1 to 10
14 Write a program to find LCM,HCF of 2
integers
15 Write a program to determine whether a
number is a perfect number, an
Armstrong number or a palindrome
16 Write a program to Count and display
the number of vowels, consonants,
uppercase, lowercase characters in
string
17 Write a program to print fibonacci
series
18 Write a program to find largest and
smallest number from list

19 Write a program to input a list of


numbers and swap elements at the even
location with the elements at the odd
location
20 Write a program to Input a tuple of
elements, search for a given element in
the tuple
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
Acknowledgement

First of all, I would like to thank my school, management, principal for giving me
the opportunity to become the part of learning process at Tagore International
School. I am extremely thankful to my teachers and mentors who helped me to
understand the python programming and its fundamentals. I hereby certify that all
the python codes written in this file are written, tested and execute by me in Python
IDE version 3.12.3 in CS Lab. This is my original work and done under the
guidance of my CS mentor.

Name:

Class: Teacher’s Signature

Stream:

Roll No:
Experiment No. 1

Title : Addition of Two Numbers


Code :
a=5
b=5
c=a+b
print("Sum of a + b =",c)

Output: 10
Experiment No. 2

Title : Print Table of 2

Code:

for i in range(1,11):

print(i*2)

Output:

10

12

14

16

18

20
Experiment No. 3

Title : Print cube from 1 to 10

Code:

for i in range(1,11):

print(i**3)

Output:

27

64

125

216

343

512

729

1000
Experiment No. 4

Title: Print series 1, 4, 7, 10, 13, 17

Code:

for i in range(0,7):

print(i*3+1)

Output:

10

13

16

19
Experiment No. 5

Title: Print series 1, 4, 7, 10, 13, 16…..

Code: for i in range(0,7):

print(i*3+1)

Output:

10

13

16

19
Experiment No. 6

Title: Calculate the area of rectangle

Code:

print("Area of rectangle")

L=6

B=3

print(Area=L*B)

Output:

Area=18
Experiment No. 7

Title: Check whether number is even or odd

Code:

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

if a/2:

print('even')

else:

print("odd")

Output:

a=2

Even
Experiment No. 8

Title: Write a program of basic calculator

Code:

print("Addtion")

i=int(input("Enter Ist number="))

j=int(input("Enter 2nd number="))

k=i+j

print("Sum = ",k)

print("Subtraction")

y=int(input("Enter 3rd number="))

t=int(input("Enter 4th number="))

x=y-t

print("Sum = ",x)

print("Multiplication")

c=int(input("Enter 5th number="))

n=int(input("Enter 6th number="))

q=c*n

print("Sum = ",q)

print("Division")

m=int(input("Enter 7th number="))

p=int(input("Enter 8th number="))

o=m/p
print("Sum = ",o)

Output:

Addtion

Enter Ist number=1

Enter 2nd number=2

Sum = 3

Subtraction

Enter 3rd number=3

Enter 4th number=2

Sum = 1

Multiplication

Enter 5th number=1

Enter 6th number=2

Sum = 2

Division

Enter 7th number=1

Enter 8th number=2

Sum = 0.5
Experiment No. 9

Title: Write a program to check if number is positive or negative

Code:

a=int(input("Enter a no."))

if a>0:

print("Positive number")

if a<0:

print("Negative number")

Output:

5 ,Positive number
Experiment No. 10

Title: Write a program to print 1 to 10

Code:

for i in range(1,11):

print(i)

Output:

10
Experiment No. 11

Title: Write a program to print 6 to 10 from range 1 to 10

Code:

for i in range(1,11):

if i >5:

print(i)

Output:

10
Experiment No. 12

Title: Write a program to print 1 to 5 from range 1 to 10

Code:

for i in range(1,11):

if i <6:

print(i)

Output:

5
Experiment No. 13

Title: Write a program to print 5 from range 1 to 10

Code:

for i in range(1,11):

if i ==5:

print(i)

Output: 5
Experiment No. 14

Title: Write a program to find LCM, HCF of 2 integers

Code:

# Input two integers

a = int(input("Enter the first number: "))

b = int(input("Enter the second number: "))

# Calculating HCF (GCD) using loop and if-else

x, y = a, b

while y != 0:

if x > y:

x=x-y

else:

y=y-x

hcf = x

# Calculating LCM using the relationship: LCM * HCF = a * b

lcm = abs(a * b) // hcf

# Print the results

print(f"HCF: {hcf}")

print(f"LCM: {lcm}")
Output:

Enter the first number: 4

Enter the second number: 2

HCF: 2

LCM: 4
Experiment No. 15

Title: Write a program to determine whether a number is a perfect number, an


Armstrong number or a palindrome

Code:

# Input the number

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

# Check for Perfect Number

sum_of_divisors = 0

for i in range(1, num):

if num % i == 0:

sum_of_divisors += i

if sum_of_divisors == num:

print(f"{num} is a Perfect Number.")

else:

print(f"{num} is not a Perfect Number.")

# Check for Armstrong Number

temp = num

sum_of_digits = 0

num_of_digits = len(str(num))
while temp > 0:

digit = temp % 10

sum_of_digits += digit ** num_of_digits

temp = temp // 10

if sum_of_digits == num:

print(f"{num} is an Armstrong Number.")

else:

print(f"{num} is not an Armstrong Number.")

# Check for Palindrome

temp = num

reversed_num = 0

while temp > 0:

digit = temp % 10

reversed_num = reversed_num * 10 + digit

temp = temp // 10

if reversed_num == num:

print(f"{num} is a Palindrome.")

else:
print(f"{num} is not a Palindrome.")

Output:

Enter a number: 5

5 is not a Perfect Number.

5 is an Armstrong Number.

5 is a Palindrome.
Experiment No. 16

Title: Write a program to Count and display the number of vowels, consonants,
uppercase, lowercase characters in string

Code:

# Input a string

string = input("Enter a string: ")

# Initialize counters

vowel_count = 0

consonant_count = 0

uppercase_count = 0

lowercase_count = 0

# Define sets of vowels for easy checking

vowels = "aeiouAEIOU"

# Iterate through each character in the string

for char in string:

if char.isalpha(): # Check if the character is a letter

if char in vowels:

vowel_count += 1
else:

consonant_count += 1

if char.isupper():

uppercase_count += 1

elif char.islower():

lowercase_count += 1

# Display the results

print(f"Vowels: {vowel_count}")

print(f"Consonants: {consonant_count}")

print(f"Uppercase letters: {uppercase_count}")

print(f"Lowercase letters: {lowercase_count}")

Output:

Enter a string: Hello,everyone,I AM Good

Vowels: 10

Consonants: 10

Uppercase letters: 5

Lowercase letters: 15
Experiment No. 17

Title: Write a program to Display the terms of a Fibonacci series

Code:

# Input the number of terms to display in the Fibonacci series

n = int(input("Enter the number of terms in the Fibonacci series: "))

# Initialize the first two terms

a, b = 0, 1

# Check if the number of terms is valid

if n <= 0:

print("Please enter a positive integer.")

elif n == 1:

print(f"Fibonacci series: {a}")

else:

print("Fibonacci series:")

count = 0

while count < n:

print(a, end=" ")

# Update the next term in the series

temp = a + b

a=b
b = temp

count += 1

Output:

Enter the number of terms in the Fibonacci series: 7

Fibonacci series:

0112358
Experiment No. 18

Title: Write a program to display the largest and smallest number from the list

Code:

# Input a list of numbers

numbers = input("Enter numbers separated by spaces: ")

# Convert the input string into a list of integers

number_list = list(map(int, numbers.split()))

# Initialize variables to store the largest and smallest numbers

largest = number_list[0]

smallest = number_list[0]

# Iterate through the list to find the largest and smallest numbers

for num in number_list:

if num > largest:

largest = num

if num < smallest:

smallest = num

# Display the results

print(f"Largest number: {largest}")


print(f"Smallest number: {smallest}")

Output:

Enter numbers separated by spaces: 2 4 6 8 66 45 32

Largest number: 66

Smallest number: 2
Experiment No. 19

Title: Write a program to input a list of numbers and swap elements at the even
location with the elements at the odd location

Code:

# Input a list of numbers

numbers = input("Enter numbers separated by spaces: ")

# Convert the input string into a list of integers

number_list = list(map(int, numbers.split()))

# Swap elements at even indices with odd indices

for i in range(0, len(number_list) - 1, 2):

# Swap the elements

number_list[i], number_list[i + 1] = number_list[i + 1], number_list[i]

# Display the modified list

print("List after swapping elements at even and odd locations:")

print(number_list)

Output:

Enter numbers separated by spaces: 1 2 3 4 5 6

List after swapping elements at even and odd locations:

[2, 1, 4, 3, 6, 5]
Experiment No. 20

Title: Write a program to Input a tuple of elements, search for a given element in
the tuple

Code:

# Input a tuple of elements

elements = input("Enter elements of the tuple separated by spaces: ")

# Convert the input string into a tuple

tuple_elements = tuple(elements.split())

# Input the element to search for

search_element = input("Enter the element to search for: ")

# Search for the element in the tuple

if search_element in tuple_elements:

print(f"{search_element} found in the tuple at index


{tuple_elements.index(search_element)}.")

else:

print(f"{search_element} not found in the tuple.")

Output:

Enter elements of the tuple separated by spaces: 1 2 3 4 5 6


Enter the element to search for: 3

3 found in the tuple at index 2.


Experiment No. 21

Title: 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

Code:

# Initialize an empty dictionary to store student data

students = {}

# Input the number of students

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

# Loop to input student details

for _ in range(n):

roll_number = input("Enter roll number: ")

name = input("Enter name: ")

marks = float(input("Enter marks: "))

# Store the details in the dictionary

students[roll_number] = {'name': name, 'marks': marks}

# Display names of students with marks above 75

print("Students with marks above 75:")


for student in students.values():

if student['marks'] > 75:

print(student['name'])

Output:

Enter the number of students: 3

Enter roll number: 1

Enter name: a

Enter marks: 87

Enter roll number: 2

Enter name: b

Enter marks: 45

Enter roll number: 3

Enter name: c

Enter marks: 98

Students with marks above 75:

You might also like