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

Python Lab Exercise 1-10

The document provides 10 questions asking to write algorithms and draw flowcharts for various tasks such as finding the greatest of two numbers, checking if a number is even or odd, checking if a number is a palindrome, checking if a number is prime, adding two numbers, finding the youngest age, calculating the area of a circle, finding Armstrong numbers, calculating the average of 5 subjects, and calculating the average age of 10 players. For each question, the algorithm is provided in pseudocode along with a placeholder for the flowchart and Python code.

Uploaded by

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

Python Lab Exercise 1-10

The document provides 10 questions asking to write algorithms and draw flowcharts for various tasks such as finding the greatest of two numbers, checking if a number is even or odd, checking if a number is a palindrome, checking if a number is prime, adding two numbers, finding the youngest age, calculating the area of a circle, finding Armstrong numbers, calculating the average of 5 subjects, and calculating the average age of 10 players. For each question, the algorithm is provided in pseudocode along with a placeholder for the flowchart and Python code.

Uploaded by

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

QUESTION 1:

Aim:
Write an algorithm and draw a flowchart to find the greatest of two numbers.

Algorithm:

1. Read a, b .
2. If a>b.
3. Display “a is the largest number”.
4. Display “b is the largest number”

Raptor:

Python Code:
QUESTION 2:

Aim:
Write an algorithm and draw a flowchart to find the given number is odd or even.

Algorithm:
1. Take integer variable
2. Assign value to the variable
3. Perform A modulo 2 and check result if output is 0.
4. If true print A is even
5. If false print A is odd.

Raptor:

Python Code:
QUESTION 3:

Aim:
Write an algorithm and draw a flowchart to find whether the given number is a palindrome or not.

Algorithm:
1. Get the number a from user.
2. Declare variables a , temp, rev.
3. Assign a=sum ,temp=0 and rev=0.
4. Hold the number a as a temporary variable.
5. Assign temp=num%10.
6. Assign num=num+temp and sum=sum/10.
7. If num==0 and rev=a, print “It is a palindrome number”.
8. If rev≠a , then print “It is not a palindrome number”.

Flowchart:
Python code:

QUESTION 4:

Aim:
Write an algorithm and draw a flowchart to check whether the given number is a prime number or not.

Algorithm:
1. Read the number from the user.
2. Assign b=0 and c=1.
3. If b>=a,check whether c=1.
4. If b≠a,then check whether a%b=0 then assign c=c+1
5. If a%b≠0 then assign b=b+1
6. Repeat Until c=1.
7. If b=0 ,then print 'The given number is prime'
8. If b≠0, then print 'The given number is not prime'
Flowchart:

Python code:
QUESTION 5:

Aim:
Write an algorithm and draw a flowchart to add two numbers.

Algorithm:
1. Declare variable.
2. Take the input of two numbers.
3. Apply the formula for addition.
4. Add two numbers.
5. Store the result in a variable.
6. Print the result.

Flowchart:

Python code:
QUESTION 6:

Aim:
Write a algorithm and draw a flowchart to find the youngest in age.

Algorithm:
1. Declare the variable a and b as the age.
2. Check if the given a<b.
3. If a<b,print a is younger.
4. Else ,print b is younger.

Flowchart:

Python code:
QUESTION 7:

Aim:
Write an algorithm and draw a flowchart to find the area of a circle of radius r.

Algorithm:
1. Start.
2. Integer area,radius.
3. Print "enter the radius of circle - "
4. Area=3.14*radius*radius.
5. Print "area of circle = "
6. Print area.

Flowchart:

Python code:
QUESTION 8:

Aim:
Write an algorithm and draw a flowchart to find find Amstrong numbers.

Algorithm:
1. Declare Variable num,order and temp=num.
2. Read num and order from User.
3. Initialize Variable sum=0 and temp=num.
4. Repeat Until sum=num.
• sum=sum + digit**order.
• Digit=temp%10
• temp=floor(temp/10)
5. IF sum=num ,then Print "It is an Armstrong Number" 6. If
sum=num ,then Print "It is not an Armstrong Number".

Flowchart:
Python code:

QUESTION 9:

Aim:
Write an algorithm and draw a flowchart to find the average of 5 subjects.

Algorithm:
1. Declare the 5 suject marks as physics,maths,science,chemistry,English
2. Read the values of the 5 subjects.
3. Assingn sum to sum of marks scored in all the 5 subjects.
4. Find the average by dividing the sum by total number of subjects.
5. Print the average.

Flowchart:
Python code:

Question 10:

Aim:
Write an algorithm and draw a flowchart to find the average age of 10 players.

Algorithm:
1. Input ages of 10 players in array A
2. Sum = 0.
3. I = 0.
4. Repeat steps 6 & 7 while (I < 10)
5. Sum = Sum + A[I]
6. I = I + 1.
7. Avg = Sum / 10.
Flowchart:

Python code:

You might also like