728x90
반응형
You are going to write a virtual coin toss program. It will randomly tell the user "Heads" or "Tails".
Important, the first letter should be capitalised and spelt exactly like in the example e.g. "Heads", not "heads".
There are many ways of doing this. But to practice what we learnt in the last lesson, you should generate a random number, either 0 or 1. Then use that number to print out "Heads" or "Tails".
e.g. 1 means Heads 0 means Tails
Example Output
Heads
or
Tails
# Write your code below this line 👇
# Hint: Remember to import the random module first. 🎲
import random
random_number = random.randint(0,1)
if random_number == 1:
print("Heads")
else:
print("Tails")
728x90
반응형
'python' 카테고리의 다른 글
[Python] ADDING EVEN NUMBERS (0) | 2023.11.02 |
---|---|
[python]파이썬 for문 반복문 (0) | 2023.11.01 |
[python] BANKER ROULETTE 풀기 (0) | 2023.10.27 |
[python] DAY 3 - LOVE CALCULATOR 풀기 (1) | 2023.10.26 |
[Python] 파이썬의 숫자처리 및 F-String (0) | 2023.10.24 |