Skip to main content
elearn.ellak.gr
  • Home
  • More
You are currently using guest access
Log in
Home
  1. Open Courses in English
  2. python_ellak_may_2017
  3. Week 2 - May 14
  4. Assignment 2.1
Assignment

Assignment 2.1

Assignment 2.1

Completion requirements
Opened: Saturday, 13 May 2017, 9:55 AM

Coin flip tossercoin flip

  • Create a program that will print a random 0 or 1.
  • Instead of 0 or 1, print heads or tails. Do this using if statements.
  • Add a loop so that the program does this 50 times.
  • Create a running total for the number of heads flipped, and the number of tails.

A starting example - it is not the complete code. There inshelp inside the comments.

Search for random command here

import random #number_of_heads = 0 #number_of_tails = 0 #for i in range(50): x = random.randint(0,1) #print(x) if x == 0: print("head") else: print("tails")
◄ Worksheet 02
Assignment 2.1 - Answer ►
You are currently using guest access (Log in)
Data retention summary
Get the mobile app
Powered by Moodle