-
Notifications
You must be signed in to change notification settings - Fork 1
PythonResources
Chris Kimpton edited this page Jan 22, 2019
·
13 revisions
Python language covered per CodeClub project
1. About Me
- print('') and multi-line using print(''' ... ''')
- repeat chars - print('&*' * 10)
- maths - print(3 - 1)
- variables - myvar = 1
- input - myvar = input('What...')
- convert to int - int(myvar)
- imports - from random import randint, myvar = randint(1,3)
- conditional logic, like, note the colons and two space (or tab) indent
- if myvar == 1:
- othervar = '2'
- elif myvar == 2:
- othervar = '3'
- else:
- othervar = '4'
3. Turtle Race
- from turtle import *
- moves - forward(100)
- write(0)
- loops, like so - remember colon and indents like above
- for step in range(5):
- write(step)
- forward(20)
4. Team Chooser
- find a char in a string - pos = "123".find('2')
- modulo - % 5 % 2 => 1
- lookup char pos in string - "123"[2] => "3"
- loop chars in string
- for char in mystring:
- add to end of string - a='1', b='2', a+=b => a is now '12'
And some useful links
- Free ebooks on learning Python - http://readwrite.com/2011/03/25/python-is-an-increasingly-popu
- Python for Kids - http://www.nostarch.com/pythonforkids
- Python Basics - http://www.amazon.co.uk/Python-Basics-Level-Coding-Club/dp/1107658551/ref=sr_1_15?s=books&ie=UTF8&qid=1417641992&sr=1-15&keywords=python+in+books
- http://jupyter.org/ - more for data analysis - but might be of interest
- http://interactivepython.org/runestone/static/StudentCSP/index.html - interactive ebook to learn python