100% found this document useful (1 vote)
2K views1 page

Cheat Sheet Tunring Scratch Into Python A3 DIGITAL

This cheat sheet provides a summary of basic Python concepts like variables, conditionals, loops, lists, and functions. It shows how to write simple Python code for input/output, selection, variables, and concatenation.

Uploaded by

tansnvarma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
2K views1 page

Cheat Sheet Tunring Scratch Into Python A3 DIGITAL

This cheat sheet provides a summary of basic Python concepts like variables, conditionals, loops, lists, and functions. It shows how to write simple Python code for input/output, selection, variables, and concatenation.

Uploaded by

tansnvarma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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 hand


card = input('Which card did you pick?') 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: delete 1 of hand hand.pop(0)
say foo is greater than 10 print("foo is greater than 10")
else elif foo < 10:
print("foo is less than 10")
if foo < 10 then
else:
LOOPS
say foo is less than 10
print("foo is equal to 10")
else
forever
say foo is equal to 10
while True:
change foo by 1 foo += 1

VARIABLES
repeat until foo > 10
while not foo > 10:
print(foo)
say foo
set foo to 10 foo = 10
bar = "some text"
set bar to some text

repeat 10
for i in range(10):
say hello print('hello')
foo = foo + 1
change foo by 1 #or
foo += 1

CONCATENATION
RANDOM
set foo to join hello world foo = "hello" + "world!"
set foo to pick random 1 to 10 from random import randint
foo = randint(1, 10)

Raspberry Pi Foundation, UK registered charity 1129409

You might also like