I Puc Lab Manual 2024-25
I Puc Lab Manual 2024-25
SECTION -A
PROGRAM 1
1. Write a program to swap two numbers using a third variable.
Program 1 : Flowchart:
x = int(input("Enter the value of x"))
y = int(input("Enter the value of y"))
print("Values of variables before swapping")
print("Value of x:", x)
print("Value of y:", y)
temp = x
x=y
y = temp
print("Values of variables after swapping")
print("Value of x:", x)
print("Value of y:", y)
Output 1:
Enter the value of x 5
Enter the value of y 10
Values of variables before swapping
Value of x: 5
Value of y: 10
Values of variables after swapping
Value of x: 10
Value of y: 5
Output 2:
Enter the value of x -1
Enter the value of y-5
Values of variables before swapping
Value of x: -1
Value of y: -5
Values of variables after swapping
Value of x: -5
Value of y: -1
*****
PROGRAM 2
MES PU COLLEGES 1
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Write a program to enter two integers and perform all arithmetic operations on them.
Program: Flowchart:
Output 1:
Output 2:
*****
PROGRAM 3
MES PU COLLEGES 2
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Write a Python program to accept length and width of a rectangle and compute its perimeter
and area.
Program: Flowchart:
Output 1:
Enter length of the rectangle: 10
Enter breadth of the rectangle: 20
Area of rectangle = 200.0
Perimeter of rectangle = 400.0
Output 2:
Enter length of the rectangle: 5
Enter breadth of the rectangle: 15
Area of rectangle = 75.0
Perimeter of rectangle = 150.0
*****
PROGRAM 4
MES PU COLLEGES 3
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Write a Python program to calculate the amount payable if money has been lent on simple
interest. Principal or money lent = P, Rate of interest = R% per annum and Time = T years.
Then Simple Interest (SI) = (P x R x T)/ 100.
Amount payable = Principal + SI.
P, R and T are given as input to the program.
Program: Flowchart:
principal = float(input('Enter amount: '))
time = float(input('Enter time: '))
rate = float(input('Enter rate: '))
simple_interest = (principal*time*rate)/100
print('Simple interest is: ',simple_interest)
Output 1:
Enter amount: 1000
Enter time: 2
Enter rate: 5
Simple interest is: 100.0
Output 2:
Enter amount: 2000
Enter time: 3
Enter rate: 4
Simple interest is: 240.0
*****
PROGRAM 5
Write a Python program to find largest among three numbers.
MES PU COLLEGES 4
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Flowchart:
Program:
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
num3 = float(input("Enter third number: "))
if (num1 >= num2) and (num1 >= num3):
largest = num1
elif (num2 >= num1) and (num2 >= num3):
largest = num2
else:
largest = num3
print("The largest number is", largest)
Output 1: Output 2:
Enter first number: 5 Enter first number: 3
Enter second number: 10 Enter second number: 2
Enter third number: 15 Enter third number: 4
The largest number is 15.0 The largest number is 4.0
*****
PROGRAM 6
MES PU COLLEGES 5
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Write a program that takes the name and age of the user as input and displays a message
whether the user is eligible to apply for a driving license or not. (The eligible age is 18
years).
Flowchart:
Program:
name = input("What is your name? ")
age = int(input("What is your age? "))
if age >= 18:
print("You are eligible to apply for the driving license.")
else:
print("You are not eligible to apply for the driving license.")
Output 1:
What is your name? Anusha
What is your age? 20
You are eligible to apply for the driving license.
Output 2:
What is your name? Sahana
What is your age? 15
You are not eligible to apply for the driving license.
*****
PROGRAM 7
MES PU COLLEGES 6
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Write a program that prints minimum and maximum of five numbers entered by the user.
Flowchart:
Program:
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)
Output 1:
Enter the number: 3
MES PU COLLEGES 7
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Output 2:
Enter the number: 2
Enter the number: 3
Enter the number: 4
Enter the number: 5
Enter the number: 6
The smallest number is 2
The largest number is 6
*****
PROGRAM 8
Write a python program to find the grade of a student when grades are allocated as given in
the table below. Percentage of Marks Grade
MES PU COLLEGES 8
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Above 90% A
80% to 90% B
70% to 80% C
60% to 70% D
Below 60% E
Percentage of the marks obtained by the student is input to the program.
Flowchart:
Program:
n = float(input('Enter the percentage of the student: '))
if(n > 90):
print("Grade A")
elif(n > 80):
print("Grade B")
elif(n > 70):
print("Grade C")
elif(n >= 60):
print("Grade D")
else:
print("Grade E")
Output 1: Output 2:
Enter the percentage of the student: 90 Enter the percentage of the student: 60
Grade B Grade D
*****
PROGRAM 9
Write a python program to print the table of a given number. The number has to be entered
by the user
MES PU COLLEGES 9
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Flowchart:
Algorithm:
Step 1: START
Step 2: INPUT num
Step 3: while count <= 10
prd = num * count
print(num, 'x', count, '=', prd)
count += 1
Step 4:OUTPUT prd
Step 5: STOP
Program:
num = int(input("Enter the number: "))
count = 1
while count <= 10:
prd = num * count
print(num, 'x', count, '=', prd)
count += 1
Output 1: Output 2:
Enter the number: 5 Enter the number: 3
5x1=5 3x1=3
5 x 2 = 10 3x2=6
5 x 3 = 15 3x3=9
5 x 4 = 20 3 x 4 = 12
5 x 5 = 25 3 x 5 = 15
5 x 6 = 30 3 x 6 = 18
5 x 7 = 35 3 x 7 = 21
5 x 8 = 40 3 x 8 = 24
MES PU COLLEGES 10
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
5 x 9 = 45 3 x 9 = 27
5 x 10 = 50 3 x 10 = 30
*****
PROGRAM 10
Write a program to find the sum of digits of an integer number, input by the user
flowchart:
Algorithm:
Step 1: START
Step 2: INPUT n
Step 3: sum=0
Step 4: while n > 0:
digit = n % 10
sum = sum + digit
n = n//10
Step 4:OUTPUT sum
Step 5: STOP
Program:
MES PU COLLEGES 11
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Output 1:
Enter the number: 123
The sum of digits of the number is 6
Output 2:
Enter the number: 457
The sum of digits of the number is 16
*****
PROGRAM 11
Write a program to check whether an input number is a palindrome or not.
Flowchart:
Algorithm:
Step 1: START
Step 2: INPUT num
Step 3: temp = n
MES PU COLLEGES 12
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
reverse = 0
Step 4: while(n>0):
digit = n % 10
reverse = reverse*10 + digit
n = n // 10
Step 5: if(temp == reverse):
print("Palindrome")
else:
print("Not a Palindrome”)
Step 6:OUTPUT reverse
Step 7: STOP
Program:
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”)
Output 1: Output 2:
Enter a number:5 Enter a number:12
Palindrome Not a Palindrome
*****
PROGRAM 12
Write a python program to print the following patterns:
12345
1234
123
12
1
Flowchart:
Algorithm:
Step 1: START
Step 2: INPUT rows
Step 3: for i =rows down to 0
for j in range(1,i+1):
MES PU COLLEGES 13
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
print(j)
Step 5: STOP
Program:
rows = int(input("Enter the number of rows: "))
for i in range(rows,0,-1):
for j in range(1,i+1):
print(j, end=" ")
print()
Output 1:
Enter the number of rows: 3
123
12
1
Output 2:
Enter the number of rows: 5
12345
1234
123
12
1
*****
SECTION -B
PROGRAM B1
Write a program that uses a user defined function that accepts name and gender (as M for
Male, F for Female) and prefixes Mr/Ms on the basis of the gender.
Flowchart:
MES PU COLLEGES 14
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Algorithm:
Step 1: START
Step 2: INPUT name,gender
Step 3: prefix(name,gender)
Step 4: OUTPUT j
Step 5: STOP
prefix(name,gender):
Step 1: 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")
Program:
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")
Output 1:
Enter your name: DEEPA
Enter your gender: M for Male, and F for Female: F
MES PU COLLEGES 15
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Output 2:
Enter your name: RAM
Enter your gender: M for Male, and F for Female: M
Hello, Mr. RAM
*****
PROGRAM B2
Write a program that has a user defined function to accept the coefficients of a quadratic
equation and calculate its determinant. For example: if the coefficients are stored in the
variables a,b,c then calculate determinant as b2-4ac. Write the appropriate condition to
check determinants as positive, zero and negative and print appropriate result.
Flowchart:
Algorithm:
Step 1: START
Step 2: INPUT a,b,c
Step 3: det = discriminant(a,b,c)
Step 4: if (det > 0):
print("The quadratic equation has two real roots.")
elif (det == 0):
print("The quadratic equation has one real root.")
MES PU COLLEGES 16
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
else:
print("The quadratic equation doesn't have any real root.“)
Step 5: OUTPUT j
Step 6: STOP
discriminant(a, b, c):
Step 1 : d = b**2 - 4 * a * c
Step 2 : return d
Program:
def discriminant(a, b, c):
d = b**2 - 4 * a * c
return d
print("For a quadratic equation in the form of ax^2 + bx + c = 0")
a = int(input("Enter the value of a: "))
b = int(input("Enter the value of b: "))
c = int(input("Enter the value of c: "))
det = discriminant(a,b,c)
if (det > 0):
print("The quadratic equation has two real roots.")
elif (det == 0):
print("The quadratic equation has one real root.")
else:
print("The quadratic equation doesn't have any real root.“)
Output 1:
For a quadratic equation in the form of ax^2 + bx + c = 0
Enter the value of a: 2
Enter the value of b: 3
Enter the value of c: 4
The quadratic equation doesn't have any real root
Output 2:
For a quadratic equation in the form of ax^2 + bx + c = 0
Enter the value of a: 1
Enter the value of b: 2
Enter the value of c: 1
The quadratic equation has one real root.
Output 3:
MES PU COLLEGES 17
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
*****
PROGRAM B3
Write a python program that has a user defined function to accept 2 numbers as parameters,
if number 1 is less than number 2 then numbers are swapped and returned, i.e., number 2 is
returned in place of number1 and number 1 is reformed in place of number 2, otherwise the
same order is returned.
Flowchart:
Algorithm:
Step 1: START
Step 2: INPUT x,y
Step 3: x, y = swapN(x, y)
Step 4: OUTPUT x,y
MES PU COLLEGES 18
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Step 5: STOP
swapN(a, b):
Step 1 : if(a < b):
return b,a
else:
return a,b
Program:
def swapN(a, b):
if(a < b):
return b,a
else:
return a,b
Output 1:
Enter Number 1: 2
Enter Number 2: 5
Entered values are :
Number 1: 2 Number 2: 5
Returned value from swap function:
Number 1: 5 Number 2: 2
Output 2:
Enter Number 1: 5
Enter Number 2: 2
Entered values are :
Number 1: 5 Number 2: 2
Returned value from swap function:
Number 1: 5 Number 2: 2
*****
PROGRAM B4
MES PU COLLEGES 19
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Write a python program to input line(s) of text from the user until enter is pressed. Count
the total number of characters in the text (including white spaces),total number of
alphabets, total number of digits, total number of special symbols and total number of words
in the given text. (Assume that each word is separated by one space).
Flowchart:
False
True False
False
True
True
Algorithm:
Step 1: START
Step 2: INPUT userInput
Step 3: totalChar = len(userInput)
Step 4: totalAlpha = 0
totalDigit = 0
MES PU COLLEGES 20
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
totalSpecial = 0
totalSpace = 0
Step 4: for a in userInput:
if a.isalpha():
totalAlpha += 1
elif a.isdigit():
totalDigit += 1
elif a.isspace():
totalSpace += 1
else:
totalSpecial += 1
Step 4: OUTPUT totalAlpha, totalDigit,totalSpecial, totalSpace + 1
Step 5: STOP
Program:
userInput = input("Write a sentence: ")
totalChar = len(userInput)
print("Total Characters: ",totalChar)
totalAlpha = totalDigit = totalSpecial = totalSpace = 0
for a in userInput:
if a.isalpha():
totalAlpha += 1
elif a.isdigit():
totalDigit += 1
elif a.isspace():
totalSpace += 1
else:
totalSpecial += 1
Output 1:
Write a sentence: WELCOME TO PYTHON PROGRAMMING
Total Characters: 29
Total Alphabets: 26
Total Digits: 0
Total Special Characters: 3
Total Words in the Input : 4
Output 2:
Write a sentence: HELLO 123
Total Characters: 9
MES PU COLLEGES 21
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Total Alphabets: 5
Total Digits: 3
Total Special Characters: 1
Total Words in the Input: 2
*****
PROGRAM B5
Write a user defined function to convert a string with more than one word into title case
string where string is passed as parameter. (Title case means that the first letter of each
word is capitalised)
Flowchart:
Algorithm:
Step 1: START
Step 2: INPUT userInput
Step 3: convertToTitle(userInput)
Step 5: STOP
convertToTitle(string):
Step 1 : titleString = string.title();
Step 2 : OUTPUT titleString
Program:
def convertToTitle(string):
titleString = string.title();
print("The input string in title case is:",titleString)
userInput = input("Write a sentence: ")
convertToTitle(userInput)
MES PU COLLEGES 22
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Output 1:
Write a sentence: hello world
The input string in title case is: Hello World
Output 2:
Write a sentence: HELLO WORLD
The input string in title case is: Hello World
*****
PROGRAM B6
Write a python program that takes a sentence as an input parameter where each word in the
sentence is separated by a space. The function should replace each blank with a hyphen and
then return the modified sentence.
Algorithm:
Step 1: START
Step 2: INPUT userInput
Step 3: result = replaceChar(userInput)
Step 4: OUTPUT result
Step 5: STOP
replaceChar(string):
Step 1 : return string.replace(' ','-')
MES PU COLLEGES 23
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Flowchart:
Program:
def replaceChar(string):
return string.replace(' ','-')
userInput = input("Enter a sentence: ")
result = replaceChar(userInput)
print("The new sentence is:",result)
Output 1:
Enter a sentence: HELLO COMPUTER SCIENCE
The new sentence is: HELLO-COMPUTER-SCIENCE
Output 2:
Enter a sentence: PYTHON PROGRAMMING
The new sentence is: PYTHON-PROGRAMMING
*****
MES PU COLLEGES 24
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
PROGRAM B7
Write a python program to find the number of times an element occurs in the list.
Algorithm:
Step 1: START
Step 2: INPUT list1,inp
Step 3: count = list1.count(inp)
Step 4: OUTPUT count
Step 5: STOP
Flowchart:
Program:
list1 = [10, 20, 30, 40, 50, 60, 20, 50, 10, 30, 50, 30, 24, 45]
print("The list is:",list1)
inp = int(input("Enter the element to count in the list: "))
count = list1.count(inp)
print("The count of element",inp,"in the list is:", count)
Output 1:
The list is: [10, 20, 30, 40, 50, 60, 20, 50, 10, 30, 50, 30, 24, 45]
Which element occurrence would you like to count? 20
The count of element 20 in the list is: 2
Output 2:
The list is: [10, 20, 30, 40, 50, 60, 20, 50, 10, 30, 50, 30, 24, 45]
Which element occurrence would you like to count? 80
The count of element 80 in the list is: 0
MES PU COLLEGES 25
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
*****
PROGRAM B8
Write a python function that returns the largest element of the list passed as parameter.
Algorithm:
Step 1: START
Step 2: INPUT list1
Step 3: max_num = largestNum(list1)
Step 4: OUTPUT max_num
Step 5: STOP
largestNum(list1):
Step 1 : length = len(list1)
Step 2 : num = 0
Step 3 : for i in range(length):
if(i == 0 or list1[i] > num):
num = list1[i]
Step 4 : return num
Flowchart:
MES PU COLLEGES 26
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Program:
def largestNum(list1):
length = len(list1)
num = 0
for i in range(length):
if(i == 0 or list1[i] > num):
num = list1[i]
return num
list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
max_num = largestNum(list1)
print("The elements of the list",list1)
print("\nThe largest number of the list:",max_num)
Output:
The elements of the list [1, 2, 3, 4, 5, 6, 7, 8, 9]
The largest number of the list: 9
*****
PROGRAM B9
Write a python program to read a list of elements. Modify this list so that it does not contain
any duplicate elements, i.e., all elements occurring multiple times in the list should appear
only once.
Algorithm:
Step 1: START
Step 2: INPUT inp
Step 3: for i in range(inp):
INPUT a
list1.append(a)
Step 4: OUTPUT list1,removeDup(list1)
Step 5: STOP
removeDup(list1):
Step 1 : length = len(list1)
Step 2 : newList = []
Step 3 : for a in range(length):
if list1[a] not in newList:
newList.append(list1[a])
Step 4 : return newList
MES PU COLLEGES 27
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Flowchart:
Program:
def removeDup(list1):
length = len(list1)
newList = []
for a in range(length):
if list1[a] not in newList:
newList.append(list1[a])
return newList
list1 = []
inp = int(input("How many elements do you want to add in the list? "))
for i in range(inp):
a = int(input("Enter the elements: "))
list1.append(a)
print("The list entered is:",list1)
print("The list without any duplicate element is:",removeDup(list1))
Output 1:
How many elements do you want to add in the list? 3
Enter the elements: 10
MES PU COLLEGES 28
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Output 2:
How many elements do you want to add in the list? 4
Enter the elements: 10
Enter the elements: 20
Enter the elements: 30
Enter the elements: 30
The list entered is: [10, 20, 30, 30]
The list without any duplicate element is: [10, 20, 30]
*****
PROGRAM B10
Write a python program to read email IDs of n number of students and store them in a tuple.
Create two new tuples, one to store only the usernames from the email IDs and second to
MES PU COLLEGES 29
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
store domain names from the email IDs. Print all three tuples at the end of the program.
[Hint: You may use the function split ()]
Flowchart:
Program:
emails = tuple()
username = tuple()
domainname = tuple()
MES PU COLLEGES 30
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Output 1:
How many email ids you want to enter? 2
> [email protected]
> [email protected]
Output 2:
How many email ids you want to enter? 1
> [email protected]
MES PU COLLEGES 31
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Program:
name = tuple()
n = int(input("How many names do you want to enter?: "))
for i in range(0, n):
num = input("> ")
name = name + (num,)
MES PU COLLEGES 32
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Output 1:
How many names do you want to enter? 3
> Ram
> Shyam
> Shiv
Output 2:
How many names do you want to enter?: 3
> Ram
> Shyam
> Shiv
*****
PROGRAM B12a
Write a Python program to create a dictionary from a string.
Note: Track the count of the letters from the string. Sample string: ‘2nd PU Course'
Expected output:
{'2': 1, 'n': 1, 'd': 1, ' ': 2, 'P': 1, 'U': 1, 'C': 1, 'o': 1, 'u': 1, 'r': 1, 's': 1, 'e': 1}
Flowchart:
MES PU COLLEGES 33
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Program:
myStr="2nd PU Course"
print("The input string is:",myStr)
myDict=dict()
for c in myStr:
if c in myDict:
myDict[c]+=1
else:
myDict[c]=1
print("The dictionary created from characters of the string is:")
print(myDict)
Output 1:
The input string is: 2nd PU Course
The dictionary created from characters of the string is:
{'2': 1, 'n': 1, 'd': 1, ' ': 2, 'P': 1, 'U': 1, 'C': 1, 'o': 1, 'u': 1, 'r': 1, 's': 1, 'e': 1}
*****
PROGRAM B12b
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.
Flowchart:
MES PU COLLEGES 34
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
Program:
no_of_std = int(input("Enter number of students: "))
result = {}
for i in range(no_of_std):
print("Enter Details of student No.", i+1)
roll_no = int(input("Roll No: "))
std_name = input("Student Name: ")
marks = int(input("Marks: "))
result[roll_no] = [std_name, marks]
MES PU COLLEGES 35
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
print(result)
for student in result:
if result[student][1] > 75:
print("Student's name who get more than 75 marks is/are",(result[student][0]))
Output 1:
Enter number of students: 2
Enter Details of student No. 1
Roll No: 01
Student Name: Anusha
Marks: 55
Enter Details of student No. 2
Roll No: 02
Student Name: Moksh
Marks: 85
{1: ['Anusha', 55], 2: ['Moksh', 85]}
Student's name who get more than 75 marks is/are Moksh
Output 2:
Enter number of students: 3
Enter Details of student No. 1
Roll No: 01
Student Name: Shiv
Marks: 87
Enter Details of student No. 2
Roll No: 02
Student Name: Ram
Marks: 56
Enter Details of student No. 3
Roll No: 03
Student Name: Robert
Marks: 74
{1: ['Shiv', 87], 2: ['Ram', 56], 3: ['Robert', 74]}
Student's name who get more than 75 marks is/are Shiv
*****
VIVA VOCE
Important Questions and Answers
1. What is a class?
A template from which objects are created.
2. What is an object?
An object is a real-world entity that has attributes(data) and behaviours(functions).
3. What is the full form of OOP?
Object Oriented Programming.
4. Mention any two OOP languages.
C++, Java and Python.
MES PU COLLEGES 36
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
22. Give any one input function of Python. Write its syntax.
input ()-used for accepting user input.
Syntax: variable =input ([prompt])
23. Give any one output function of Python. Write its syntax.
print()-used for displaying the results on screen.
Syntax: print(value [, ..., sep=’ ’, end = '\n'])
24. What is a comment?
A non-executable statement in program is called a comment.
25. How to define single line comment?
A single line comment can be added using # symbol.
Example: # My first program in Python.
MES PU COLLEGES 37
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
MES PU COLLEGES 38
DEPARTMENT OF COMPUTER SCIENCE I PUC LAB MANUAL
*****
MES PU COLLEGES 39