0% found this document useful (0 votes)
3 views3 pages

Revision Tour

The document outlines a series of programming tasks that involve creating menu-driven programs for various operations on lists and strings. Tasks include searching elements, sorting lists, finding maximum and minimum values, and working with names and strings to analyze their properties. Additional tasks involve prime number calculations, creating dictionaries, and handling employee records.

Uploaded by

musicallthewayyy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Revision Tour

The document outlines a series of programming tasks that involve creating menu-driven programs for various operations on lists and strings. Tasks include searching elements, sorting lists, finding maximum and minimum values, and working with names and strings to analyze their properties. Additional tasks involve prime number calculations, creating dictionaries, and handling employee records.

Uploaded by

musicallthewayyy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

REVISION TOUR

Q1.Write a Menu driven program to create a user defined list of integers and do the following:
a. Search an element in a list given by user
b. Sort the list in ascending order
c. Find the highest and lowest element in a list without sorting.
L1 = [] NUM = INT(INPUT("ENTER THE NUMBER OF ELEMENTS IN THE LIST: ")) FOR I IN RANGE(NUM): ELM =
INT(INPUT("ENTER THE ELEMENT OF THE LIST: ")) L1.APPEND(ELM) RETURN L1 DEF SEARCHELEMENT(L1):
SEARCHELEMENT = INT(INPUT("PLEASE ENTER THE ELEMENT TO BE SEARCHED: ")) IF SEARCHELEMENT IN L1: INDEX =
L1.INDEX(SEARCHELEMENT) PRINT(SEARCHELEMENT, "FOUND AT INDEX", INDEX) ELSE: PRINT(SEARCHELEMENT, "NOT
FOUND IN LIST") DEF SORTLIST(L1): SORTEDLIST = SORTED(L1) PRINT("THE LIST HAS BEEN SORTED IN ASCENDING
ORDER:", SORTEDLIST) RETURN SORTLIST DEF FIND_MAX_MIN(L1): IF LEN(L1) > 0: MAX = MAX(L1) MIN = MIN(L1)
PRINT("THE HIGHEST ELEMENT:", MAXIMUM) PRINT("THE LOWEST ELEMENT:", MINIMUM) ELSE: PRINT("LIST IS
EMPTY.") DEF MAIN(): L1 = CREATE_LIST() PRINT("INITIAL LIST:", L1) WHILE TRUE: PRINT("\N THE LIST HAS THE
FOLLOWING ELEMENTS:", L1) PRINT("SELECT THE TASK TO PERFORM ON LIST:") PRINT("1. SEARCH AN ELEMENT IN A
LIST GIVEN BY USER") PRINT("2. SORT THE LIST IN ASCENDING ORDER") PRINT("3. FIND THE MAX AND MIN ELEMENT IN
A LIST") PRINT("4. EXIT") CHOICE = INT(INPUT("ENTER YOUR CHOICE: ")) IF CHOICE == 1: SEARCH_ELEMENT(L1) ELIF
CHOICE == 2: L = SORT_LIST(L1) ELIF CHOICE == 3: FIND_MAXIMUM_MINIMUM(L1) ELIF CHOICE == 4:
PRINT("EXITING THE PROGRAM.") BREAK ELSE: PRINT("INVALID CHOICE") MAIN() OUTPU

OUTPUT
Q2.Write a Menu drive program to create a user defined list of names and do the following : a.
Find the name with longest length. b. Print all the names starting with vowels. c.Print the names
having maximum numbers of alphabet „e‟ present in it.

Q3.Write a Menu drive program to enter a strings and do the following : a. To count total
numbers of spaces in a string b. To find vowel, consonants, digits and special characters in a
string. c. To print the longest word of a string. d.To print the word having maximum “a”
present in it.

Q4.Write a Menu drive program to enter a strings and do the following: a. To check whether
the string is palindrome or not b. To print all the words of a string in reverse order. c. To
remove all special characters from a string.

Q5.Write a Menu driven program to do the following: a. Print all prime numbers upto N b. To
print the following pyramid 1 123 1234 12345 c. To find the sum of the series 1! + 2! + 3! + ……
+n!

Q6. Write a Menu program to create a dictionary with „key‟ as Rollno and „Value‟ Name of
the students. a. Using this dictionary create two different lists one containing the names of all
odd rollno other containing the even numbers. b. Print the Rollno of all students having names
starting with „A‟

Q7. Write a program to create 3 lists : Empno, Name and Salary. Now do the following : a.
Using above list create a dictionary { “Emp No” :[List of empno], “Name” :[List of Names],
“Salary”:[List of Salary]} b. Search and display record of given employee from dictionary.

Q8. Write a Menu driven program to do the following: a. To find the sum of odd and even
numbers upto N separately. b. To check whether the number is prime or not. c.To check
whether the number if Armstrong or not.

You might also like