Python Exercises - Solving Algorithms with Python

Pybeginner
By -
0


Exercise # 01 - Write an algorithm for adding two numbers in Python

Algorithm

STEP 1: Start
STEP 2: Accept the first number a.
STEP 3: Accept the second number b.
STEP 4: Add a and b and store in SUM.
STEP 5: Display the SUM value.
STEP 6. Stop


flowchart

Exercise #02 - Write an algorithm to print the largest number between two numbers in Python

 

Algorithm

STEP 1: Start
STEP 2: Read the two numbers a and b.
STEP 3: Compare a and b.
If a is greater than b, print a, otherwise, print b.
STEP 4: Stop

 

flowchart




Exercise #03 - Write an algorithm to print the largest number out of three numbers in Python

 

Algorithm

STEP 1: GET STARTED
STEP 2: Read three numbers and store them in A, B, C
STEP 3: It's A> B
{Yes: Go to Step 6, No: Go to Step 4}
STEP 4: It's B> C
{Yes: printing B is better, no: go to step 5}
STEP 5: Printing C is better and go go to step 8}
STEP 6: It is A> C
{Yes: printing A is better, No: go to step 7}
STEP 7: Printing C is better and go to Step 8
STEP 8: Stop

 

flowchart




Exercise #04 - Write an algorithm to print the first ten natural numbers in Python

 

Algorithm

STEP 1: Get started.
STEP 2: Initialize the variable count to one.
STEP 3: Display the variable count.
STEP 4: Increase the variable count by one.
STEP 5: Check that the count variable exceeds 10.
If yes, go to step 3, if not go to step 6
STEP 6: Stop

 

flowchart




Exercise #05 - Write an algorithm to print Circle Area in Python

 

Algorithm

STEP 1 : Start
STEP 2: Read the 'r' ray.
STEP 3: Store 3.14 worth of pi.
STEP 4: Find the area of ​​the circle (Area = pi * r * r)
STEP 5: Display area.
STEP 6: Stop

 

flowchart




Exercise #06 - Write an Algorithm to Calculate Simple Interest in Python


Algorithm

STEP 1: Begin
STEP 2: Read Principal, Time and Rate (P, T, R)
STEP 3: Calculate Simple Interest (JS = P * T * R / 100)
STEP 4: Display JS
STEP 5: Stop

 

flowchart





 

Exercise #07 - Write an algorithm to print out whether a number is Positive, Negative or Zero in Python.

 

Algorithm

Step 1Read number.
Step 2If the number is less than zero, then it is a negative integer.
Step 3Else if the number is greater than zero, then it is a positive integer.
Step 4Else, the number is equal to zero.
Step 3: End.

 

flowchart




Post a Comment

0Comments

Post a Comment (0)