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

2 Beginner Python Cheatsheet

This document is a concise cheatsheet for beginners in Python, covering essential concepts such as variables, data types, control flow, loops, functions, lists, and dictionaries. It provides examples of syntax and usage for each topic, emphasizing the importance of practicing by writing and running code. Key built-in functions are also highlighted to aid in programming tasks.

Uploaded by

saad.bouachrine1
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)
4 views2 pages

2 Beginner Python Cheatsheet

This document is a concise cheatsheet for beginners in Python, covering essential concepts such as variables, data types, control flow, loops, functions, lists, and dictionaries. It provides examples of syntax and usage for each topic, emphasizing the importance of practicing by writing and running code. Key built-in functions are also highlighted to aid in programming tasks.

Uploaded by

saad.bouachrine1
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

Python for Beginners — Essential Cheatsheet

A concise reference for the most important Python concepts and syntax.

Variables and Data Types


Python supports several built-in data types. You declare a variable simply by assigning a value —
no keyword needed.

name = 'Alice' # string


age = 30 # integer
height = 1.75 # float
is_student = True # boolean

Control Flow
Use if / elif / else to make decisions in your code:

if age >= 18:


print('Adult')
elif age >= 13:
print('Teenager')
else:
print('Child')

Loops
for i in range(5): # prints 0 to 4
print(i)

while count > 0: # loop while condition is true


count -= 1

Functions
Define reusable blocks of code with the def keyword:

def greet(name):
return f'Hello, {name}!'

print(greet('Alice')) # Hello, Alice!

Lists and Dictionaries


fruits = ['apple', 'banana', 'cherry'] # list
[Link]('date') # add item
print(fruits[0]) # apple

person = {'name': 'Bob', 'age': 25} # dictionary


print(person['name']) # Bob

Useful Built-In Functions


len(fruits) — number of items
type(age) — data type of a variable
range(start, stop, step) — generate number sequences
input('Enter: ') — read user input
int(), float(), str() — type conversion

Tip: Practice every concept by typing it yourself. Reading code alone is not enough — writing and
running it is how real learning happens.

You might also like