karnan1999
Badges: 5
Rep:
?
#1
Report Thread starter 5 years ago
#1
Hi. I'm doing the OCR Computing A453 Programming Project and I have to write a pseudocode of how my code works.

This is the question.
A primary school teacher wants a computer program to test the basic arithmetic skills of her students. The program should generate a quiz consisting of a series of random questions, using in each case any two numbers and addition, subtraction and multiplication. The system should ask the student’s name, then ask 10 questions, output if the answer to each question is correct or not and produce a final score out of 10.
Analyse the requirements in detail and design, code, test and evaluate a program to meet these requirements

This is my code:
import random

correct = 0
name = input("Please state your name: ")
for count in range(10):
num1 = random.randint(1, 10)
num2 = random.randint(1, 10)
symbol = random.choice(["+", "-", "*"])
print("Please solve:\n", num1, symbol, num2)
user = int(input(""))

if symbol == "+":
answer = num1 + num2
elif symbol == "-":
answer = num1 - num2
elif symbol == "*":
answer = num1 * num2

if user == answer:
print("Correct!")
correct = correct + 1
else:
print("Incorrect")

print(name, ", You Got", correct, "Out Of 10")

Please help us we have a shtty computing teacher who hasnt taught us crap and I'm having to learn things all by myself. Can someone help me write this up in PSEUDOCODE THANKS
1
reply
nerak99
Badges: 13
Rep:
?
#2
Report 5 years ago
#2
First of all you can pretty much present what you have as pseudo code.
However, (1) Indent blocks of code. (2) You could change method calls such as random.choice(["+", "-", "*"]) to functions like this

a) Change random.choice(["+", "-", "*"]) to symbol = get__random_operator()
b) Add a function like
function get__random_operator()
n=random_integer(4)
case i of random_integer
1: return "+"
2: return "-"

....
end;

This means that you pseudo code does not contain anything too language specific

I assume you code is indented and TSR removed the indenting as it has for me!
1
reply
benjosh30
Badges: 2
Rep:
?
#3
Report 3 years ago
#3
what the ****
1
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

If you haven't confirmed your firm and insurance choices yet, why is that?

I don't want to decide until I've received all my offers (4)
50%
I am waiting until the deadline in case anything in my life changes (2)
25%
I am waiting until the deadline in case something in the world changes (ie. pandemic-related) (1)
12.5%
I am waiting until I can see the unis in person (0)
0%
I still have more questions before I made my decision (0)
0%
No reason, just haven't entered it yet (0)
0%
Something else (let us know in the thread!) (1)
12.5%

Watched Threads

View All