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

Python - Pseudocode Answer Key

The document provides an answer key for various programming exercises in Python and pseudocode. It includes examples of loops, conditionals, and functions, demonstrating how to perform tasks such as printing numbers, checking even/odd, and calculating surface area and volume. Each exercise is presented in both Python code and corresponding pseudocode format.

Uploaded by

deval
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)
2 views6 pages

Python - Pseudocode Answer Key

The document provides an answer key for various programming exercises in Python and pseudocode. It includes examples of loops, conditionals, and functions, demonstrating how to perform tasks such as printing numbers, checking even/odd, and calculating surface area and volume. Each exercise is presented in both Python code and corresponding pseudocode format.

Uploaded by

deval
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

IT Worksheet answer key:​


Pseudocode/Python code programs:

1.
Python:
i=1
while i <= 10:
print (i)
i +=1

Pseudocode:

Start
i=1
while i is 10 or less:
output i
Add 1 to i
End

2.

Python:

for i in range(1, 10 + 1):


print(i)

Pseudocode:

Start
FOR i from 1 to 10:
OUTPUT i
End

3.

Python:

i=2
while i <= 20:
print(i)
i += 2
Pseudocode:

Start
Set i to 2
Repeat while i is less than or equal to 20:
Output i
Add 2 to i
End

4.

Python:

num = int(input("Enter a number: "))


r = int(input("Enter the range: "))
for i in range(1, r + 1):
print(num, "*", i, "=", num * i)

Pseudocode:

Start
Input num
Input r
For i from 1 to r:
Output num * i in format: num * i = result
End

5.

Python:

num = int(input("Input Number: "))


if num % 2 == 0:
print("even")
else:
print("odd")

Pseoudocode:

Start
Input num
If num mod 2 = 0 then
Output "even"
Else
Output "odd"
End

6.

Python:

age = int(input("Enter your age: "))

if age >= 18:


print("You are eligible to vote.")
else:
print("You are not eligible to vote.")

Pseudocode:

Start
Input age
If age is 18 or more then
Output "You are eligible to vote"
Else
Output "You are not eligible to vote"
End

7.

Python:

def surface_area(l, w, h):


area = 2 * (l * w + w * h + h * l)
print("Surface Area:", area)

def volume(l, w, h):


vol = l * w * h
print("Volume:", vol)

length = int(input("Enter length: "))


width = int(input("Enter width: "))
height = int(input("Enter height: "))

surface_area(length, width, height)


volume(length, width, height)

Pseudocode:
Start

Define function area(length, width, height):


surface_area = 2 × (length × width + width × height + height × length)
Output "Surface Area:", surface_area

Define function volume(length, width, height):


volume = length × width × height
Output "Volume:", volume

Main:
Input length
Input width
Input height

Call area(length, width, height)


Call volume(length, width, height)

End

8.

Python:

i = 10
while i >= 1:
print(i)
i -= 1

Pseudocode:

Start
Set i to 10
While i is greater than or equal to 1:
Output i
Subtract 1 from i
End

9.

Python:

for num in range(1200, 2201):


if num % 7 == 0 and num % 5 == 0:
print(num)

Pseudocode:

Start
For num from 1200 to 2200:
If num mod 7 = 0 and num mod 5 = 0 then
Output num
End

10.

Python:

length = float(input("Enter the length: "))


width = float(input("Enter the width: "))

area = length * width


perimeter = 2 * (length + width)

print("Area:", area)
print("Perimeter:", perimeter)

Pseudocode:

Start
Input length
Input width

Set area = length × width


Set perimeter = 2 × (length + width)

Output area
Output perimeter
End

You might also like