Twa kɔ nsɛm atitiriw so
Log in
Sign up for FREE
arrow_back
Laabri

Programming Rock, Paper, Scissors Part 2 OALH

star
star
star
star
star
Last updated about 4 years ago
22 Nsɛmmisa
1
1
1
1
1
1
1

Now run the following code in trinket below

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

Use the trinket below to write your rock paper scissors code

Asemmisa {{asɛmmisaAhyɛnsode}}
1.

What is a variable?

Asemmisa {{asɛmmisaAhyɛnsode}}
2.

What is the convention for naming variables?

Asemmisa {{asɛmmisaAhyɛnsode}}
3.

What is an f-string used for?

Asemmisa {{asɛmmisaAhyɛnsode}}
4.

Look at the following code

If the input was 14 what would the output be?

Asemmisa {{asɛmmisaAhyɛnsode}}
5.

What would happen if the string “crab” was entered instead of a number?

Asemmisa {{asɛmmisaAhyɛnsode}}
6.
Draggable itemarrow_right_altCorresponding Item

Char

arrow_right_alt

False

Integer

arrow_right_alt

"Hello"

String

arrow_right_alt

"a"

Boolean

arrow_right_alt

5.2

Real/float

arrow_right_alt

283

Asemmisa {{asɛmmisaAhyɛnsode}}
7.

Predict: try to make a prediction about what might happen when this code is executed.

Asemmisa {{asɛmmisaAhyɛnsode}}
8.

What data type is being collected at line 2?

Asemmisa {{asɛmmisaAhyɛnsode}}
9.

Run the program and type more than 1 character when asked for your first initial.

What happens?

Asemmisa {{asɛmmisaAhyɛnsode}}
10.

Why do you think this is?

Asemmisa {{asɛmmisaAhyɛnsode}}
11.

Does Python have a function for char?

Asemmisa {{asɛmmisaAhyɛnsode}}
12.

Run the program and type in some string (text) when you are asked for your age. What happens?

Asemmisa {{asɛmmisaAhyɛnsode}}
13.

Why do you think this happens?

Asemmisa {{asɛmmisaAhyɛnsode}}
14.

Run the program and type in all lower case true when asked if you like marmite. What happens to the marmite message?

Asemmisa {{asɛmmisaAhyɛnsode}}
15.

Run the program and type in True when asked if you like marmite. What happens to the marmite message?

Asemmisa {{asɛmmisaAhyɛnsode}}
16.

Run the program and type in hello when asked if you like marmite. What happens to the marmite message?

Asemmisa {{asɛmmisaAhyɛnsode}}
17.

Line 12 contains the following piece of code likes_marmite == marmite". What do you think might be happening here?

Asemmisa {{asɛmmisaAhyɛnsode}}
18.

Run the program and type 9 when you are asked for your age. What happens?

Asemmisa {{asɛmmisaAhyɛnsode}}
19.

On line 10, the forward slash / is being used between the variable age and the number 10. What arithmetic operation is the forward slash performing?

Asemmisa {{asɛmmisaAhyɛnsode}}
20.

On line 10, change the word float to int. Run the code and type in 9 as your age. What happens?

Asemmisa {{asɛmmisaAhyɛnsode}}
21.

Keeping line 10 as int. Run the code and type in 28 as your age. What happens?

Asemmisa {{asɛmmisaAhyɛnsode}}
22.

What do you think is happening when the number is held as an integer compared to a float?