Presentation is loading. Please wait.

Presentation is loading. Please wait.

GCSE Computing.

Similar presentations


Presentation on theme: "GCSE Computing."— Presentation transcript:

1 GCSE Computing

2 If statement password = input(“Enter your password”) if password == “bish”: print(“access granted”) else: print(“Access denied”) input(“\n\nPress enter to continue”)

3 Username & Password (elif)
username = “ “ while not username: loops until username entered username = input(“Enter username: “) #Same code for password with while not password if username == “Bert” and password == “secret”: print(“Hey Burt”) elif username == “Ernie” and password ==“cookies”: print(“Hey, Ernie”) #Elif for more options – think of two more combos else: print(“log in failed”) #code for key to exit

4 Modifications to the dice game
Add a while loop that repeats the game until the user enters “N” when asked to play again. Add input for user to enter prediction before rolling the dice. Add input for stake of bet Use if statement to decide whether the prediction is the same as the actual total and state whether they have won or lost To calculate return (Stake * 5) Extension: View table on next slide to calculate return depending on actual total (Hint: Requires Elif)

5 Total Prob Return 2 1/36 =Stake*30 3 1/18 =stake*15 4 1/12 =stake*10 5
Using the elif option calculate the return depending on what total is entered. E.g. if pred == 2: return = stake * print(“You have won: “, return) elif ***** - continue coding ******* Total Prob Return 2 1/36 =Stake*30 3 1/18 =stake*15 4 1/12 =stake*10 5 1/9 =stake*8 6 5/36 =stake*6 7 1/6 =stake*4 8 9 10 11 12 =stake*30

6 Selection (using IF) Easy task – Create a program that accepts a number from the keyboard. If the number is larger than 100 the message “larger than 100” is shown on the screen otherwise “less than 100 is shown”. Medium task – Create a program that accepts a test score from the keyboard. If the score is larger than 20 the message “You achieved an A” is outputted, if it is between 10 and 19 the message “You achieved a C” is and less than 10 “You failed the test”. Hard task – Create a program that accepts two numbers from the keyboard. The user is then asked to input if they would like to add, subtract, divide or multiply the numbers. That sum is then done with the answer shown on the screen.


Download ppt "GCSE Computing."

Similar presentations


Ads by Google