149x Filetype PDF File size 0.66 MB Source: ugc.futurelearn.com
Cheat sheet: turning Scratch into Python Try out your new text-based programming skills with these awesome Python projects: rpf.io/startpython INPUT LISTS ask Which card did you pick? and wait card = input('Which card did you pick?') hand 1 hand = ['ace', set card to answer 2 'king', 3 'queen', 4 'jack', OUTPUT 5 'ten'] say Hello World! print('Hello World!') say foo print(foo) length: 5 SELECTION add nine to hand hand.append('nine') if foo >10 then if foo > 10: 1 hand hand.pop(0) delete of say foo is greater than 10 print("foo is greater than 10") else elif foo < 10: if foo <10 then print("foo is less than 10") LOOPS else: say foo is less than 10 print("foo is equal to 10") else forever while True: say foo is equal to 10 foo += 1 change foo by 1 VARIABLES repeatuntil foo > 10 while not foo > 10: say foo print(foo) set foo to 10 foo = 10 bar bar = "some text" set to some text repeat 10 for i in range(10): foo = foo + 1 say hello print('hello') change foo by 1 #or foo += 1 CONCATENATION RANDOM set foo to join hello world foo = "hello" + "world!" set foo to pickrandom 1 to 10 from random import randint foo = randint(1, 10) Raspberry Pi Foundation, UK registered charity 1129409
no reviews yet
Please Login to review.