Lab Manual
Lab Manual
2024-25
SUBJECT: COMPUTER SCIENCE
CLASS : I PUC
LECTURER : SADIYA SULTANA, B.E ,MTech ,K-SET,(PhD)
x = 10
y = 50
print("Values of variables before swapping")
print("Value of x:", x)
print("Value of y:", y)
temp = x # Swapping of two variables #
x=y Using third variable
y = temp
print("Values of variables
after swapping")
print("Value of x:", x) print("Value of y:", y)
largest = num1
largest = num2
else:
largest = num3
else:
smallest = 0
largest = 0
for a in range(0,5):
x = int(input("Enter the number: "))
if a == 0:
smallest = largest = x
if(x <smallest):
smallest = x
if(x > largest):
largest = x
print("The smallest number is",smallest)
print("The largest number is ",largest)
sum = 0
n = int(input("Enter the number: "))
while n > 0:
digit = n % 10
sum = sum + digit
n = n//10
print("The sum of digits of the number is",sum)
n = int(input("Enter a number:"))
temp = n
reverse = 0
while(n>0):
digit = n % 10
reverse = reverse*10 + digit n = n // 10
if(temp == reverse):
print("Palindrome") else:
print("Not a Palindrome“)
for i in range(rows,0,-1):
#print the number from 1 to i+1
for j in range(1,i+1): #print the next row in new line
print()
Chapter 7 : Functions
def prefix(name,gender):
if (gender == 'M' or gender == 'm'): print("Hello, Mr.",name)
elif (gender == 'F' or gender == 'f'):
print("Hello, Ms.",name) else:
print("Please enter only M or F in gender")
name = input("Enter your name: ")
gender = input("Enter your gender: M for Male, and F for Female: ")
prefix(name,gender)
def convertToTitle(string):
titleString = string.title();
print("The input string in title case is:",titleString)
list1 = [10, 20, 30, 40, 50, 60, 20, 50, 10, 30, 50, 30, 24, 45]
count = list1.count(inp)
#defining a list
#printing the list for the user
#asking the element to count
#using the count function
#printing the output
emails = tuple()
username = tuple()
domainname = tuple()
n = int(input("How many email ids you want to enter?: "))
for i in range(0,n):
emid = input("> ") #Create two new tuples,
name = tuple()
n = int(input("How many names do you want to enter?: "))
for i in range(0, n):
num = input("> ")
name = name + (num,)
myStr="2nd PU Course"
myDict=dict()
if character in myDict:
myDict[character]+=1
else:
myDict[character]=1
print(myDict)
result = {}
for i in range(no_of_std):
print(result)