0% found this document useful (0 votes)
8 views

Gr11 Record Programs

Uploaded by

smithra730
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)
8 views

Gr11 Record Programs

Uploaded by

smithra730
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

PRINT THE GIVEN STRING

Program 1: To print the given message and display it.

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.

SOURCE CODE: # GCD PROGRAM


num1 = int(input("Enter 1st number: "))
num2 = int(input("Enter 2nd number: "))
i = 1 while(i <= num1 and i <= num2):
if(num1 % i == 0 and num2 % i == 0):
gcd = i
i = i + 1
print("Greatest Common Divisor (GCD) is ", gcd)
# LCM PROGRAM
if num1 > num2:
greater = num1
else:
greater = num2
while(True):
if((greater % num1 == 0) and (greater % num2 == 0)):
lcm = greater
break
greater += 1
print("The Least Common Multiple (LCM) is ", lcm)

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

Program 5: To find the largest / smallest number in a list.


SOURCE CODE:

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

Program 8: To search an item in a tuple.


SOURCE CODE:

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:

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]
print(result)
# Display names of students who have got marks more than 75
for student in result:
if result[student][1] > 75:
print ("Student name who got more than 75 marks”,
(result[student][0]))

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:

Enter number of entries2


Enter country:India
Enter Capital: Delhi Enter currency
of the country: Rupee
Enter country: China
Enter Capital Beijing
Enter currency of the country: Yuan

Country Capital Currency

India Delhi Rupee

China Beijing Yuan


Enter the country to search: India

Country Capital Currency

India Delhi Rupee

You might also like