0% found this document useful (0 votes)
3 views4 pages

Simplified Python Module 1

This document provides simplified notes on Python programming basics, including data types, variables, and control flow structures like loops and conditional statements. It also covers functions, exception handling, and examples such as a simple 'Hello, World!' program and a 'Guess the Number' game. Key concepts include using the Python Shell (IDLE), string manipulation, and importing modules.
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)
3 views4 pages

Simplified Python Module 1

This document provides simplified notes on Python programming basics, including data types, variables, and control flow structures like loops and conditional statements. It also covers functions, exception handling, and examples such as a simple 'Hello, World!' program and a 'Guess the Number' game. Key concepts include using the Python Shell (IDLE), string manipulation, and importing modules.
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/ 4

Python Programming - Module 1 (Simplified Notes)

1. Python Basics

1.1 Using the Python Shell (IDLE)

- IDLE is where we can type and run Python code line-by-line.

- Example:

>>> 2 + 2

1.2 Data Types in Python

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

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

- str: Text values in quotes (e.g., 'Hello')

- Examples:

age = 20 # int

pi = 3.14 # float

name = 'Alice' # str

1.3 String Concatenation and Replication

- '+' joins strings: 'Hello' + ' World' -> 'Hello World'

- '*' repeats strings: 'Hi' * 3 -> 'HiHiHi'

1.4 Variables

- Variables store data.

- Example:

x=5

y=x+3

print(y) # Output: 8

1.5 Your First Program

print("Hello, World!")
Python Programming - Module 1 (Simplified Notes)

1.6 Input and Output

- input(): Takes user input as a string.

- print(): Displays output.

- Example:

name = input("Enter your name: ")

print("Hello, " + name)

2. Flow Control

2.1 Boolean Values

- Only two values: True or False

2.2 Comparison Operators

- ==, !=, <, >, <=, >=

2.3 Boolean Operators

- and: True if both are true

- or: True if at least one is true

- not: Reverses the value

2.4 If, elif, else Statements

- if: runs a block if condition is True

- elif: more conditions

- else: if nothing above is true

2.5 While Loops

- Repeats a block while a condition is True

2.6 For Loops with range()


Python Programming - Module 1 (Simplified Notes)

- Repeat a block for a fixed number of times

- Example:

for i in range(5):

print(i)

2.7 Break and Continue

- break: Exit the loop early

- continue: Skip the rest and go to next loop

2.8 Importing Modules

- Use `import module_name` to use extra features

- Example: import random

2.9 sys.exit()

- Use to exit the program early

3. Functions

3.1 Defining a Function

- def hello(): defines a function

3.2 Parameters and Return

- Functions can take inputs and return values

- Example:

def add(a, b):

return a + b

3.3 None Value

- Special value meaning "nothing"


Python Programming - Module 1 (Simplified Notes)

3.4 Keyword Arguments in print()

- print('Hi', end='!') prints without newline

3.5 Local and Global Variables

- Local: inside function

- Global: outside all functions

3.6 Global Statement

- Allows modifying global variables inside functions

3.7 Exception Handling

- try and except to handle errors

3.8 Example: Guess the Number Game

- Uses input(), random, if-else, loops, etc.

You might also like