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

Computer Science Practical File 2024-25

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)
12 views35 pages

Computer Science Practical File 2024-25

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

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 [Link](): # Check if the character is a letter

if char in vowels:

vowel_count += 1
else:

consonant_count += 1

if [Link]():

uppercase_count += 1

elif [Link]():

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, [Link]()))

# 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, [Link]()))

# 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([Link]())

# 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 [Link]():

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:

Common questions

Powered by AI

Misunderstanding scope and lifetime of variables can lead to significant implications in programming, such as unexpected behavior from variables retaining unwanted values, memory leaks, and logic errors due to incorrect variable access. In the context of the provided programs, global versus local variable misuse can lead to incorrect outputs, especially when dealing with loops or recursive functions where iterative states should be isolated. Proper grasp ensures predictable program execution and maintenance of variable states, crucial for debugging and optimizing complex applications .

The experiments illustrate several programming paradigms: procedural programming (through step-by-step instructions like loops and conditionals), object-oriented thinking (implicit in data structures like dictionaries), and functional elements (through operations on lists, tuples). Collectively, these paradigms expose students to diverse methods of problem-solving, enhancing flexibility in programming approaches. They cultivate a comprehensive understanding of computational logic, enabling students to select appropriate paradigms based on problem context and scalability needs, thus adding depth to a computer science curriculum .

The structure of a practical file in computer science, like the one used at Tagore International School, includes various hands-on programming tasks such as basic arithmetic operations, loops for series generation, conditional statements for determining number properties, and data structures like lists and dictionaries. This structured approach allows students to apply theoretical concepts practically, thereby reinforcing learning and enabling them to understand programming fundamentals through experimentation and iteration .

Projects like programs to identify perfect, Armstrong, and palindrome numbers provide pedagogical benefits by encouraging students to deeply engage with mathematical concepts and algorithms. They promote computational thinking as students have to break down the problem, apply conditions, and iteratively test solutions. These tasks foster critical problem-solving skills and demonstrate the practical application of logical operations and control structures, thus bridging theoretical knowledge with real-world programming challenges .

In the program to check if a number is even or odd, a logical flaw exists where the condition 'if a/2:' won't reliably determine evenness because it doesn't check for divisibility without remainder. Instead, it should be 'if a % 2 == 0:' to correctly identify even numbers. Errors that may arise from this flaw include false positives where numbers are incorrectly identified as even. Error handling in Python can be implemented using 'try-except' blocks to catch and manage unexpected input types that would lead to runtime errors, although the logic must primarily be corrected to fix the intended functionality .

The program swapping elements at even and odd locations in a list can be optimized by minimizing operations and ensuring better memory efficiency. Instead of manually iterating and swapping sequentially, using a single pass loop with index manipulations or leveraging list comprehensions or built-in functions could enhance performance. These optimizations can reduce time complexity and improve code readability and maintainability, ultimately leading to faster execution and reduced overhead in applications involving large datasets .

Integrating a practical file submission system enhances students' preparedness for real-world software development by instilling a sense of accountability and project management skills. It encourages thorough documentation and iterative development practices akin to real-world scenarios. Students learn to manage deadlines, revisions, and receive structured feedback, simulating a professional software development environment. This exposure helps in understanding lifecycle models and collaborative workflows essential in industry contexts .

Students might face challenges such as correctly handling case sensitivity, differentiating between vowels and consonants, and managing non-letter characters. Strategies to address these include using functions like .lower()/upper() for case normalization, leveraging character sets for vowel checks, and ensuring input validation to filter out non-alphabetic entries. Additionally, students should test with diverse input cases to ensure robustness and learn from debugging processes, fostering deeper understanding of string handling nuances .

The basic calculator program illustrates fundamental programming concepts such as input/output operations, arithmetic operations (addition, subtraction, multiplication, and division), and the use of variables to store and manipulate data. These concepts prepare students for more advanced computational tasks by establishing a solid understanding of data processing workflows and user interaction through program interfaces. By grasping these basics, students can efficiently approach more complex problems like algorithm design, data analysis, and system programming .

Tuple operations, as demonstrated in student exercises like searching an element in a tuple, are effective for teaching data manipulation concepts because they introduce students to immutable data structures. This reinforces understanding of data storage versus modification. The exercise teaches efficient access and lookup operations, valuable in contexts where data integrity must be preserved. The simplicity of operations within the tuple context helps students focus on algorithm efficiency and precision in searches and manipulations .

You might also like