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

Algorithm

Uploaded by

hhabibulla344
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Algorithm

Uploaded by

hhabibulla344
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Algorithm

step-by-step algorithms for programs 1 to 20, with detailed steps.

---

1. Create, Append, and Remove Lists

Steps:

1. Start the program.

2. Create an empty list or initialize a list with some elements.

3. Append a new element to the list using append().

4. Print the updated list.

5. Remove an element using remove() or pop().

6. Print the final list.

7. End the program.

---

2. Working with Tuples

Steps:

1. Start the program.

2. Define a tuple with multiple elements.

3. Access and print specific elements using indexing.

4. Attempt to modify the tuple to confirm its immutability.

5. Print the results.

6. End the program.

---

3. Working with Dictionaries


Steps:

1. Start the program.

2. Create a dictionary with key-value pairs.

3. Add a new key-value pair using assignment (dict[key] = value).

4. Remove a key-value pair using del or pop().

5. Print the updated dictionary.

6. End the program.

---

4. Find the Largest of Three Numbers

Steps:

1. Start the program.

2. Input three numbers.

3. Use conditional statements (if-else) or the max() function to determine the largest number.

4. Print the largest number.

5. End the program.

---

5. Convert Temperature between Celsius and Fahrenheit

Steps:

1. Start the program.

2. Define a function to convert Celsius to Fahrenheit:

3. Define another function to convert Fahrenheit to Celsius:


.

4. Input the temperature value.

5. Call the respective function for conversion.


6. Print the converted temperature.

7. End the program.

---

6. Solve Electricity Billing

Steps:

1. Start the program.

2. Input the number of units consumed.

3. Use conditional statements to calculate the bill:

For the first 100 units, charge 1.5 per unit.

For units above 100, charge 2.5 per unit.

4. Add up the total bill.

5. Print the total bill amount.

6. End the program.

---

7. Sin Series Approximation

Steps:

1. Start the program.

2. Input the angle in degrees.

3. Convert the angle to radians using .

4. Use the formula for sin series:


.

5. Print the approximated value.

6. End the program.


---

8. Solve Three-Phase AC Current

Steps:

1. Start the program.

2. Input the voltage and resistance values.

3. Use Ohm’s Law to calculate current: .

4. Print the calculated current.

5. End the program.

---

9. Exchange Two Variables

Steps:

1. Start the program.

2. Input two variables and .

3. Swap the values using simultaneous assignment: .

4. Print the variables before and after swapping.

5. End the program.

---

10. Circulate the Values of Variables

Steps:

1. Start the program.

2. Input a list of elements.

3. Move the last element to the front of the list.

4. Print the updated list.


5. End the program.

---

11. Print Number Series and Patterns

Steps:

1. Start the program.

2. Input the number of terms.

3. Use a loop to print a number series (e.g., natural numbers).

4. Use nested loops to create a number or star pattern.

5. Print the output.

6. End the program.

---

12. Print Pyramid Pattern

Steps:

1. Start the program.

2. Input the number of rows for the pyramid.

3. Use a loop to print spaces and stars to form a pyramid.

4. Print each row sequentially.

5. End the program.

---

13. Library Items using Lists and Tuples

Steps:

1. Start the program.


2. Define a list of tuples with book details (e.g., title, author).

3. Use a loop to print all items in the library.

4. End the program.

---

14. Components of a Car

Steps:

1. Start the program.

2. Define a tuple containing car components.

3. Print the elements in the tuple.

4. End the program.

---

15. Building Materials using Lists and Tuples

Steps:

1. Start the program.

2. Define a dictionary with material names and quantities.

3. Use a loop to print the details of each material.

4. End the program.

---

16. Word Count and Longest Word

Steps:

1. Start the program.

2. Input a sentence.

3. Split the sentence into words.


4. Use a loop to count the words and find the longest word.

5. Print the word count and the longest word.

6. End the program.

---

17. Explore Pygame Tool

Steps:

1. Start the program.

2. Import and initialize Pygame.

3. Create a window with defined dimensions.

4. Run an event loop to display the screen.

5. Close the window on event quit.

6. End the program.

---

18. Convert Integer to Roman Numeral

Steps:

1. Start the program.

2. Input an integer value.

3. Define a dictionary of Roman numeral symbols.

4. Use a loop to convert the integer to a Roman numeral.

5. Print the result.

6. End the program.

---
19. Bouncing Ball Game

Steps:

1. Start the program.

2. Initialize Pygame and set up the screen.

3. Define the ball's position, speed, and radius.

4. Use a loop to move the ball and check for collisions with walls.

5. Update the screen continuously.

6. End the program when the quit event occurs.

---

20. Car Race Game

Steps:

1. Start the program.

2. Initialize Pygame and create a game screen.

3. Draw a car using shapes or images.

4. Use keyboard events to move the car left or right.

5. Update the screen and check for collisions.

6. End the program when the quit event occurs.

You might also like