0% found this document useful (0 votes)
2 views2 pages

Python Beginner Cheat Sheet A4

This document is a beginner's Python cheat sheet formatted in A4, covering common symbols, variables, data types, operators, strings, input/output, conditional statements, loops, lists, dictionaries, functions, modules, and comments. It provides basic syntax and examples for each topic to aid in understanding Python programming. The cheat sheet serves as a quick reference for essential Python concepts and commands.

Uploaded by

xguess
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
0% found this document useful (0 votes)
2 views2 pages

Python Beginner Cheat Sheet A4

This document is a beginner's Python cheat sheet formatted in A4, covering common symbols, variables, data types, operators, strings, input/output, conditional statements, loops, lists, dictionaries, functions, modules, and comments. It provides basic syntax and examples for each topic to aid in understanding Python programming. The cheat sheet serves as a quick reference for essential Python concepts and commands.

Uploaded by

xguess
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/ 2

PYTHON CHEAT SHEET - BEGINNER (A4 FORMAT)

1. COMMON SYMBOLS
# Comment
() Parentheses (functions, conditions)
[] Square brackets (lists, indexing)
{} Curly braces (dictionaries, sets)
: Colon (after if, for, def, etc.)
; Semicolon (rarely used)
, Comma (separates items)
'' or "" Quotation marks (strings)
\n New line
\t Tab

2. VARIABLES & DATA TYPES


x = 5 # Integer
y = 3.14 # Float
name = 'Anna' # String
is_happy = True # Boolean
type(x) # int
type(name) # str

3. OPERATORS
+ - * / # Math: Add, Subtract, Multiply, Divide
% ** // # Modulo, Power, Floor division
== != > < # Compare: equal, not equal, greater, less
>= <= # Compare: greater or equal, less or equal
and or not # Logical
= += -= # Assignment

4. STRINGS
s = 'Hello'
s.upper() # 'HELLO'
s[0] # 'H'
'lo' in s # True
len(s) # 5

5. INPUT & PRINT


name = input('Enter your name: ')
print('Hi', name)

6. IF / ELSE
age = 20
if age >= 18:
print('Adult')
else:
print('Minor')

7. LOOPS
for i in range(3):
print(i)

count = 0
while count < 3:
print(count)
count += 1

8. LISTS
nums = [1, 2, 3]
nums.append(4)
print(nums[0]) # 1
len(nums) # 4

9. DICTIONARIES
person = {'name': 'Tom', 'age': 25}
print(person['name'])

10. FUNCTIONS
def greet(name):
print('Hi', name)

greet('Leo')

11. MODULES
import math
print(math.sqrt(9))

import random
print(random.randint(1, 5))

12. COMMENTS
# This is a comment
'''This is
a multi-line comment'''

You might also like