0% found this document useful (0 votes)
3 views

python_basics_colorful_notes

The document outlines the basics of Python programming, covering topics such as variables, data types, input/output operations, control flow, operators, nested statements, functions, and library routines. It provides examples for each concept to illustrate their usage. This serves as a foundational guide for understanding Python syntax and programming logic.

Uploaded by

afraa umer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

python_basics_colorful_notes

The document outlines the basics of Python programming, covering topics such as variables, data types, input/output operations, control flow, operators, nested statements, functions, and library routines. It provides examples for each concept to illustrate their usage. This serves as a foundational guide for understanding Python syntax and programming logic.

Uploaded by

afraa umer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Python Basics - Colorful Notes According to Syllabus

1. Declare and Use Variables and Constants


Variables store data that can change.

Example:

name = 'John' # String

age = 25 # Integer

Constants are usually written in uppercase letters:

PI = 3.14159 # Constant value

2. Understand and Use Basic Data Types


Basic data types include:

- Integer: Whole numbers (e.g., 10)

- Real (float): Decimal numbers (e.g., 3.14)

- Char: Python uses strings for characters (e.g., 'A')

- String: Sequence of characters (e.g., 'Hello')

- Boolean: True or False

3. Understand and Use Input and Output


Input and output operations:

user_input = input('Enter your name: ') # Input

print('Hello, World!') # Output

4. Control Flow Concepts


(a) Sequence: Instructions executed in order.

(b) Selection (if statements): Conditional logic.

if age > 18:

print('You are an adult.')


(c) Iteration (loops):

for i in range(5):

print(i)

while count < 5:

count += 1

5. Arithmetic, Logical, and Boolean Operators


Arithmetic: +, -, *, /, %, **

Logical: ==, <, >, <=, >=, !=

Boolean: AND, OR, NOT

6. Nested Statements
Nested if statements and loops:

if age > 18:

if age < 25:

print('Young adult')

for i in range(3):

for j in range(2):

print(i, j)

7. Procedures, Functions, and Parameters


Functions: Reusable blocks of code.

def greet(name):

return f'Hello, {name}!'

Local and global variables:

global_var = 10 # Global variable

def some_function():

local_var = 5 # Local variable


8. Library Routines
Common functions:

- MOD: % for remainder

- DIV: // for integer division

- ROUND: round(3.14159, 2) # Output: 3.14

- RANDOM:

import random

random.randint(1, 10) # Random integer

You might also like