0% found this document useful (0 votes)
50 views5 pages

Pseudocode To Python Conversion Year11

The document explains the conversion of pseudocode to Python, highlighting the syntax differences for loops, if statements, input/output, and variables. It includes examples, quiz questions, and practical exercises for converting between the two formats. Additionally, it presents a challenge task for writing pseudocode based on provided Python code.

Uploaded by

Cassi
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)
50 views5 pages

Pseudocode To Python Conversion Year11

The document explains the conversion of pseudocode to Python, highlighting the syntax differences for loops, if statements, input/output, and variables. It includes examples, quiz questions, and practical exercises for converting between the two formats. Additionally, it presents a challenge task for writing pseudocode based on provided Python code.

Uploaded by

Cassi
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/ 5

Year 11 Computer Science: Converting Pseudocode and Python

1. Explanation

Pseudocode is a human-readable way to describe algorithms using structured steps.

Python is a real programming language that requires correct syntax.

Example:

Pseudocode:

FOR i <- 1 TO 5

OUTPUT i

ENDFOR

Python:

for i in range(1, 6):

print(i)

2. Important Notes

Loops:

Pseudocode: FOR i <- 1 TO 10 => Python: for i in range(1, 11):

Pseudocode: WHILE condition => Python: while condition:

If Statements:

Pseudocode: IF condition THEN => Python: if condition:

Pseudocode: ELSE IF cond THEN => Python: elif condition:

Pseudocode: ELSE => Python: else:

Input / Output:

Pseudocode: OUTPUT "Hello" => Python: print("Hello")


Pseudocode: INPUT name => Python: name = input("Enter name: ")

Variables:

Pseudocode: SET total TO 0 => Python: total = 0

Pseudocode: total <- total + 1 => Python: total = total + 1

3. Quiz Questions

Q1. What is the Python equivalent of: SET count TO 10?

A. let count = 10

B. count := 10

C. count = 10

D. count == 10

Answer: C

Q2. What does this pseudocode do?

FOR i <- 1 TO 3

OUTPUT i * 2

ENDFOR

A. Prints 2, 4, 6

B. Prints 1, 2, 3

C. Multiplies i by 3

D. Error

Answer: A

Q3. Which is correct Python syntax?

A. IF x > 0 THEN:

B. if x > 0:

C. if x > 0 then
D. IF x > 0:

Answer: B

4. Practical Exercises

Convert Pseudocode to Python:

Pseudocode:

SET total TO 0

FOR i <- 1 TO 5

total <- total + i

OUTPUT total

Python:

total = 0

for i in range(1, 6):

total += i

print(total)

Pseudocode:

INPUT age

IF age >= 18 THEN

OUTPUT "Adult"

ELSE

OUTPUT "Minor"

Python:

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

if age >= 18:


print("Adult")

else:

print("Minor")

Convert Python to Pseudocode:

Python:

name = input("Enter name: ")

print("Hello " + name)

Pseudocode:

INPUT name

OUTPUT "Hello " + name

Python:

for i in range(3):

print(i)

Pseudocode:

FOR i <- 0 TO 2

OUTPUT i

ENDFOR

5. Challenge Task

Write pseudocode for the following Python code:

Python:

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


if num % 2 == 0:

print("Even")

else:

print("Odd")

Your Turn!

You might also like