0% found this document useful (0 votes)
5 views6 pages

Algorithm 1

The document outlines various algorithms for Python programs, including processing student marks, performing arithmetic operations, managing employee data, and conducting number-based operations. Each algorithm follows a structured approach with steps for input, processing, and output. Additionally, it includes menu-driven programs for tasks like managing contacts and performing list operations.

Uploaded by

rishysubhish22
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)
5 views6 pages

Algorithm 1

The document outlines various algorithms for Python programs, including processing student marks, performing arithmetic operations, managing employee data, and conducting number-based operations. Each algorithm follows a structured approach with steps for input, processing, and output. Additionally, it includes menu-driven programs for tasks like managing contacts and performing list operations.

Uploaded by

rishysubhish22
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/ 6

1.

Write a Python program to accept and process marks


of 10 students using a list:
Algorithm
Step 1: Start
Step 2: Create a list of marks
Step 3: Input 10 marks from user
Step 4: Find maximum mark
Step 5: Find minimum mark
Step 6: Find total and average
Step 7: Sort marks in ascending order
Step 8: Sort marks in descending order
Step 9: Print results
Step 10: Stop

2. Write a menu-driven program using functions to


perform basic arithmetic operations:

Algorithm
Step 1: Start
Step 2: Display menu (Add, Subtract, Multiply, Divide, Exit)
Step 3: Input choice from user
Step 4: If choice is Add → input two numbers → print sum
Step 5: If choice is Subtract → input two numbers → print difference
Step 6: If choice is Multiply → input two numbers → print product
Step 7: If choice is Divide → input two numbers → print quotient
Step 8: If choice is Exit → stop program
Step 9: Repeat steps 2–8 until Exit
Step 10: Stop
3. Write a Python program to manage employee data
using dictionaries:

Algorithm
Step 1: Start
Step 2: Create an empty dictionary
Step 3: Input employee details (ID, Name, Salary)
Step 4: Store details in dictionary
Step 5: Search employee by ID
Step 6: Print details if found, otherwise print not found
Step 7: Find employee with highest salary
Step 8: Print employee with highest salary
Step 9: Stop

4. Write a Python program to perform the following


number-based operations:

Algorithm
Step 1: Start
Step 2: Input a number
Step 3: Check if number is prime → print result
Step 4: Print all primes up to the number
Step 5: Find next 5 prime numbers after the given number
Step 6: Print them
Step 7: Stop
5. Write a menu-driven program to perform operations
on a list of numbers entered by the user:

Algorithm
Step 1: Start
Step 2: Input a list of numbers
Step 3: Display menu (Max/Min, Ascending, Descending, Sum/Avg, Exit)
Step 4: If choice is Max/Min → print maximum and minimum
Step 5: If choice is Ascending → print sorted list
Step 6: If choice is Descending → print sorted list
Step 7: If choice is Sum/Avg → print sum and average
Step 8: If choice is Exit → stop
Step 9: Repeat steps 3–8 until Exit
Step 10: Stop

6. Write a menu-driven program to manage a simple


contact book using a dictionary:

Algorithm
Step 1: Start
Step 2: Create empty dictionary for contacts
Step 3: Display menu (Add, Search, Display, Delete, Exit)
Step 4: If choice is Add → input name and number → save
Step 5: If choice is Search → input name → print details if found
Step 6: If choice is Display → print all contacts
Step 7: If choice is Delete → input name → remove from contacts
Step 8: If choice is Exit → stop
Step 9: Repeat steps 3–8 until Exit
Step 10: Stop
7. Write a menu-driven program to work with a number
entered by the user:

Algorithm
Step 1: Start
Step 2: Input a number
Step 3: Display menu (Prime check, Multiplication table, Armstrong check, Sum of digits,
Exit)
Step 4: If choice is Prime → print result
Step 5: If choice is Table → print multiplication table
Step 6: If choice is Armstrong → check and print result
Step 7: If choice is Sum of digits → calculate and print sum
Step 8: If choice is Exit → stop
Step 9: Repeat steps 3–8 until Exit
Step 10: Stop

8. Write a menu-driven program to perform operations


on a tuple of numbers:

Algorithm
Step 1: Start
Step 2: Input a tuple of numbers
Step 3: Display menu (Display, Max/Min, Convert & Add, Count, Exit)
Step 4: If choice is Display → print tuple
Step 5: If choice is Max/Min → print maximum and minimum
Step 6: If choice is Convert & Add → convert tuple to list → add element → convert back
Step 7: If choice is Count → input element → count frequency
Step 8: If choice is Exit → stop
Step 9: Repeat steps 3–8 until Exit
Step 10: Stop
9. Write a Python program to do the following list
operations:

Algorithm
Step 1: Start
Step 2: Input a list of numbers
Step 3: Print original list
Step 4: Input element and position to insert
Step 5: Insert element at given position
Step 6: Input element to delete
Step 7: Delete element if present
Step 8: Print updated list
Step 9: Stop

10.Find the Square and Cube of the number.

Algorithm
Step 1: Start
Step 2: Input a number
Step 3: Find square of the number
Step 4: Find cube of the number
Step 5: Print square and cube
Step 6: Stop
11.Find the Factorial of the number

Algorithm 11: Factorial


Step 1: Start
Step 2: Input a number
Step 3: Set factorial = 1
Step 4: Repeat from 1 to number → multiply with factorial
Step 5: Print factorial
Step 6: Stop

You might also like