0% found this document useful (0 votes)
6 views12 pages

Practical

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)
6 views12 pages

Practical

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/ 12

ARYA VIDYA MANDIR SR. SEC.

SCHOOL

ACADEMIC YEAR: 2024-25


PRACTICAL FILE

SUBMITTED BY NIKHIL BHARDWAJ


SUBMITTED TO:Mrs. Monika Goyal
PGT(Computer)
NAME :NIKHIL BHARDWAJ
ROLL NO. :24
CLASS/SEC. : 11th A
SUBJECT : COMPUTER SCIENCE(083)
1: Python Program To Add 2 Numbers
num1 = float(input("Enter first number: "))

num2 = float(input("Enter second number: "))

sum = num1 + num2

print("The sum of", num1, "and", num2, "is", sum)

print("Program By Nikhil")
2: Python Program To swap Two Values Without Using Third value and Display New
Value
a = float(input("Enter first number: "))

b = float(input("Enter second number: "))

a, b = b, a

print("After swapping:")

print("First number:", a)

print("Second number:", b)

print("Program By Nikhil")
3: Python Program To make a calculator
while True:

print("Select operation:")

print("1. Add")

print("2. Subtract")

print("3. Multiply")

print("4. Divide")

choice = input("Enter choice (1/2/3/4): ")

if choice in ['1', '2', '3', '4']:

num1 = float(input("Enter first number: "))

num2 = float(input("Enter second number: "))

if choice == '1':

result = num1 + num2

print(f"{num1} + {num2} = {result}")

elif choice == '2':

result = num1 - num2

print(f"{num1} - {num2} = {result}")

elif choice == '3':

result = num1 * num2

print(f"{num1} * {num2} = {result}")

elif choice == '4':

if num2 == 0:

print("Cannot divide by zero!")

else:

result = num1 / num2

print(f"{num1} / {num2} = {result}")

else:

print("Invalid input. Please enter a valid choice.")

again = input("Do you want to perform another calculation? (yes/no): ")

if again.lower() != 'yes':

print("Exiting the calculator. Program Made by Nikhil")

break
4: Python Program To Check Whether A Character Is Small Or Capital
char = input("Enter a character: ")

if len(char) == 1:

if char.islower():

print("Small letter")

elif char.isupper():

print("Capital letter")

else:

print("Not a letter")

else:

print("Please enter a single character.")

print("Program By Nikhil")
Python program to change one datatype to another:
num_str = "123"
num_int = 456
num_float = 78.90
num_list = [1, 2, 3]
str_to_int = int(num_str)
int_to_float = float(num_int)
float_to_str = str(num_float)
list_to_tuple = tuple(num_list)
tuple_to_list = list(list_to_tuple)
print("String to Integer:", str_to_int)
print("Integer to Float:", int_to_float)
print("Float to String:", float_to_str)
print("List to Tuple:", list_to_tuple)
print("Tuple to List:", tuple_to_list)
Python Program To :
(i):Traverse A List:
my_list = [10, 20, 30, 40, 50]

print("Traversing using a for loop:")

for item in my_list:

print(item)

print(“Code By Nikhil”)

(ii):A 2d List:
my_list = [[10, 20, 30, 40, 50]]

for i in my_list:

for item in i:

print(item)

print("code by Nikhil")

(iii)Python Program To Receive A List From User & Traverse It:

my_list = []

i=0

while True:

a=eval(input("Enter List Element :"))

my_list.append(a)

i=+1

again=input("AGAIN? y/n:")

if again=="n":

break

for item in my_list:

print(item)

print("Code By Nikhil")
7: Python Program To receive string from user and traverse it:

user_input = input("Please enter a string: ")


for i in user_input:
print(i)
print('program by nikhil')
Q_8 write a program to display table of any given no.?
CODE :-
number=int(input("enter any no,"))
for i in range(1,11):
print(number,"*",i,"=",number*i)
print(“program by Nikhil”)
Q-9 Write a program to following string function
(capitalize,alnum,split,replace,partition)
st="this is string function'
print(st.split("i"),"THIS IS SPLIT FUNCTION")
print(st.replace("is","was"),"THIS IS REPLACE FUNCTION")
print(st.partition("i"),"THIS IS PARTITION FUNCTION")
print(st.capitalize(),"THIS IS CAPITALIZE FUNCTION”)
print(st.isalnum())
print(“program by Nikhil”)
Q10 Create a dictionary of month where month name is key and number of days
is value now ask a user for a month name and display no. of days in that month
?
CODE:
months_days = {'January': 31,'February': 28, 'March': 31,'April': 30,'May': 31,'June': 30,'July': 31,'August':
31,'September': 30,'October':31,'November': 30,'December': 31}
month = input("Enter a month name: ")
print(month,"no. of days is",months_days[month])
print(“program by Nikhil”)

You might also like