#separator:tab
#html:false
#tags column:4
Print text to the screen	print('Hello')		tech-python-syntax
Get input from the user	input('Name? ')		tech-python-syntax
Make a variable	x = 5		tech-python-syntax
Comment a line	# this is a comment		tech-python-syntax
Integer division	7 // 2 gives 3		tech-python-syntax
Remainder (modulo)	7 % 2 gives 1		tech-python-syntax
Exponent (power)	2 ** 3 gives 8		tech-python-syntax
Not equal comparison	x != y		tech-python-syntax
Equal comparison	x == y		tech-python-syntax
Logical and	a and b		tech-python-syntax
Logical or	a or b		tech-python-syntax
Logical not	not a		tech-python-syntax
If statement	if x > 3:		tech-python-syntax
Else if	elif x == 3:		tech-python-syntax
Else	else:		tech-python-syntax
For loop over a range of 5	for i in range(5):		tech-python-syntax
Range from 1 to 10	range(1, 11)		tech-python-syntax
While loop	while x < 10:		tech-python-syntax
Stop a loop early	break		tech-python-syntax
Skip to the next loop pass	continue		tech-python-syntax
Do nothing placeholder	pass		tech-python-syntax
Define a function	def greet(name):		tech-python-syntax
Return a value	return x		tech-python-syntax
Default parameter	def f(x=10):		tech-python-syntax
Lambda (small anonymous function)	lambda x: x * 2		tech-python-syntax
Make a list	nums = [1, 2, 3]		tech-python-syntax
Add to the end of a list	nums.append(4)		tech-python-syntax
Remove last item of a list	nums.pop()		tech-python-syntax
Length of a list or string	len(nums)		tech-python-syntax
First item of a list	nums[0]		tech-python-syntax
Last item of a list	nums[-1]		tech-python-syntax
Slice the first two items	nums[:2]		tech-python-syntax
Sort a list in place	nums.sort()		tech-python-syntax
Sorted copy of a list	sorted(nums)		tech-python-syntax
Reverse a list	nums.reverse() or nums[::-1]		tech-python-syntax
Tuple (unchangeable sequence)	t = (1, 2, 3)		tech-python-syntax
Set (unique items)	s = {1, 2, 3}		tech-python-syntax
Dictionary	d = {'a': 1, 'b': 2}		tech-python-syntax
Get a dictionary value	d['a']		tech-python-syntax
Loop over dictionary items	for k, v in d.items():		tech-python-syntax
Check if item is in a list	3 in nums		tech-python-syntax
Convert to integer	int('5')		tech-python-syntax
Convert to string	str(5)		tech-python-syntax
Convert to float	float('3.5')		tech-python-syntax
Convert to list	list('abc')		tech-python-syntax
Type of a value	type(x)		tech-python-syntax
Join strings in a list	', '.join(words)		tech-python-syntax
Split a string into a list	'a b c'.split()		tech-python-syntax
Uppercase a string	'hi'.upper()		tech-python-syntax
Replace text in a string	s.replace('a', 'b')		tech-python-syntax
Strip whitespace	s.strip()		tech-python-syntax
F-string	f'Hello {name}'		tech-python-syntax
Multi-line string	'''text over lines'''		tech-python-syntax
Import a module	import math		tech-python-syntax
Import one name	from math import sqrt		tech-python-syntax
Random integer	import random; random.randint(1, 6)		tech-python-syntax
Square root	math.sqrt(16)		tech-python-syntax
Absolute value	abs(-3)		tech-python-syntax
Round a number	round(3.6)		tech-python-syntax
Maximum of values	max(1, 5, 3)		tech-python-syntax
Sum of a list	sum(nums)		tech-python-syntax
List comprehension	[x * 2 for x in nums]		tech-python-syntax
Open and read a file	with open('f.txt') as f: data = f.read()		tech-python-syntax
Handle errors	try: ... except ValueError: ...		tech-python-syntax
Raise an error	raise ValueError('bad')		tech-python-syntax
Define a class	class Dog:		tech-python-syntax
Constructor method	def __init__(self, name):		tech-python-syntax
The current object inside a method	self		tech-python-syntax
None value	None		tech-python-syntax
Boolean values	True and False		tech-python-syntax
Enumerate with index	for i, x in enumerate(nums):		tech-python-syntax
Zip two lists	zip(a, b)		tech-python-syntax
Check if a value is None	x is None		tech-python-syntax
Run code only when file is the main program	if __name__ == '__main__':		tech-python-syntax
Python's creator	Guido van Rossum, who released Python in 1991		tech-python-syntax
