Gr11 Record Programs
Gr11 Record Programs
SOURCE CODE:
welcome_message=input ("Enter welcome message: ")
print("Hello, ", welcome_message)
RESULT:
The above code has been compiled and executed successfully.
OUTPUT:
Enter welcome message : Welcome to Python
Hello, Welcome to Python
GCD & LCM OF TWO INTEGERS PROGRAM NO: 16
Program2: To compute the Greatest Common Divisor and Least Common
Multiple of two integers.
RESULT:
The above code has been compiled and executed successfully.
OUTPUT:
Enter 1st number: 2
Enter 2nd number: 4
Greatest Common Divisor (GCD) is 2
The Least Common Multiple (LCM) is 4
COUNT THE NUMBER OF VOWELS,CONSONANTS,UPPERCASE, LOWERCASE
CHARATCTERS IN STRING
PROGRAM 3: To count and display the number of vowels, consonants,
uppercase and lowercase characters in a string.
SOURCE CODE:
RESULT:
The above code has been compiled and executed successfully.
OUTPUT:
Type the string: Hello World
Number of Vowels in Hello World is : 3
Number of Consonants in Hello World is : 7
Number of UPPER Case in Hello World ' is : 2
Number of lower case in Hello World ' is : 8
PALINDROME STRING
Program 4: To input a string and determine whether it is a palindrome or not
and convert the case of characters in the string.
SOURCE CODE:
RESULT:
The above code has been compiled and executed successfully.
OUTPUT:
Enter a string: malayalam
malayalam is a Palindrome string
LARGEST / SMALLEST NUMBER IN LIST / TUPLE
RESULT:
The above code has been compiled and executed successfully.
OUTPUT:
Enter the no. of elements in the list:6
Enter the element:3
Enter the element:1
Enter the element:7
Enter the element:0
Enter the element:9
Enter the element:2
Smallest element in the list is 0
Largest element in the list is 9
Smallest element in the tuple is 0
Largest element in the tuple is 9
SWAP THE ELEMENTS IN A LIST
Program 6: To input a list of numbers and swap the elements at the even
location with the elements at the odd location.
SOURCE CODE:
RESULT:
The above code has been compiled and executed successfully.
OUTPUT:
Total list items to enter =4
Enter the element 10
Enter the element 20 Enter
the element 30
Enter the element 40
Original List : [10, 20, 30, 40]
The elements at odd location: [10, 30]
The elements at even location: [20, 40]
List after swapping : [20, 10, 40, 30]
FREQUENCY OF ELEMENTS IN A LIST
Program 7: To find the frequency of all the elements in the list.
SOURCE CODE:
RESULT:
The above code has been compiled and executed successfully.
OUTPUT:
Element Frequency
3 2
21 2
5 16
6 2
8 1
SEARCH AN ITEM IN A TUPLE
RESULT:
The above code has been compiled and executed successfully.
OUTPUT:
Enter the number of elements in a tuple5
Enter the element10 Enter
the element20
Enter the element30 Enter
the element40 Enter the
element50
Enter the element you want to search20
The element 20 is found at position 1
CREATE A DICTIONARY WITH STUDENT DETAILS
Program 9: 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.
SOURCE CODE:
RESULT:
The above code has been compiled and executed successfully.
OUTPUT:
Enter number of students: 3
Enter Details of student No. 1
Roll No: 01
Student Name: Riya
Marks: 78
Enter Details of student No. 2
Roll No: 02
Student Name: Rishab
Marks: 70
Enter Details of student No. 3
Roll No: 03
Student Name: Seena
Marks: 46
{1: ['Riya', 78], 2: ['Rishab', 70], 3: ['Seena', 46]}
Student name who got more than 75 marks Riya
DICTIONARY TO STORE COUNTRY NAME, CAPITAL AND
CURRENCY, DISPLAY THEM AND SEARCH FOT THE DETAIL
PROGRAM NO 10: To create a dictionary to store country name, capital and
currency and display them in tabular form. Then search for a country detail
and display them.
SOURCE CODE:
d=dict
i=1
n=int(input("Enter number of entries"))
while i <=n:
c=input("Enter country:")
cap=input("Enter Capital")
curr=input("Enter currency of the country")
d[c]=(cap,curr)
i=i+1
#tabular form
l=d.keys()
print("\nCountry\t\t","Capital\t\t","Currency”)
for i in l:
z=d[i]
print("\n",i,"\t\t",end="")
for j in z:
print(j,"\t\t",end="\t\t")
#Search for the detail
x=input("Enter the country to search")
for i in l:
if i==x:
print("\nCountry\t\t","Capital\t\t","Currency")
z=d[i]
print("\n",i,"\t\t",end="")
for j in z:
print(j,"\t\t",end="\t\t")
break
else:
print("The country name not found in the dictionary")
RESULT:
The above code has been compiled and executed successfully.
OUTPUT: