Your PDF starts by explaining why Python is so popular today.
Phones, laptops, smart TVs, watches generate huge amounts of data.
It has powerful libraries for:
Python is used for:
Python is a powerful, simple-to-learn programming language used everywhereβfrom websites to AI machines.
Your PDF lists several important features:
Example (from PDF):
age = 33
if age < 100:
print("Wow! I am alive!")
Simple, readable, clean.
You can download free from python.org
You can modify and redistribute Python freely.
You donβt need to worry about:
Python handles it automatically.
Contains modules for:
Runs on:
The PDF explains this clearly:
Source code β Bytecode (Compiler)
Bytecode β Machine code (Interpreter/PVM)
Compiler β catches syntax errors
Interpreter β stops program when runtime error occurs
Example in PDF (Page 242):
The block after if must be properly indented.
No need to declare type of variables.
x = 10
x = "Hello"
Python automatically frees unused memory.
Can integrate with:
Download: www.python.org/downloads
Install β Click Install Now
Then open from Start menu.
Your PDF explains Pythonβs working beautifully:
You write source code β program.py
Python compiler converts source code β bytecode (.pyc)
Python Interpreter (PVM) executes bytecode line-by-line.
IDLE = Integrated Development and Learning Environment.
Contains:
Two modes:
Example:
>>> (1 + 7) * 2
16
The PDF gives a table of arithmetic examples.
Examples:
| Command | Description |
|---|---|
2+2 | Simple addition |
43 - 7*9 | Mixed arithmetic |
(23+2*5)/5 | Division |
15/2 | 7.5 (float result) |
17//3 | Floor division |
5%2 | Remainder |
5**2 | Exponentiation (power) |
Strings = Characters inside quotes.
Examples:
"Delhi"
"12345"
'Python is cool.'
PDF example:
'Python isn't good' β ERROR
"Python isn't good" β Correct
Index starts from 0.
P S E U D O C O D E
0 1 2 3 4 5 6 7 8 9
Negative index starts from end:
E = -1
D = -2
O = -3
Accessing elements:
str[0] = P
str[-1] = E
To create a program:
.pyErrors appear in the Shell.
Two types:
# This is a comment
'''
comment lines
'''
OR
"""
comment lines
"""
Variable = Memory container for values.
Example:
name = "Arjun"
age = 16
price = 78.5
Valid:DOB, date_of_birth, ctr1
Invalid:12name, my-name, a@b
Inside quotes: "123", "Hello"
Whole numbers
Memory: 4 bytes
Very large integers (Only in old Python 2.x)
Example:149L
With decimals: 3.14, 5.78
Scientific notation:x = 7.8e3
True / False
Internally stored as 1 / 0.
Operands = values
Operators = + β * / // % **
-5 converts positive to negative.
Python converts automatically
a = 2 * 3.5 # becomes float
Using functions:
int("3")
float(5)
str(62)
input() β always returns stringprint() β shows output
Example:
n = input("What is your name?")
print("Welcome", n)
5 + 7 = 12
"5" + "7" = "57"
if number % 2 == 0:
print("Even")
if marks >= 33:
print("Pass")
else:
print("Fail")
Runs until condition becomes false.
i = 1
while i <= 10:
print(i)
i += 1
Used for iterating through a list or range.
for i in range(1, 11):
print(i)
Stops the loop.
Skips to next iteration.
Very detailed in PDF.
cities = []
nums = [10, 20, 30]
mixed = [23, 'apple', 53.4]
mylist[0] β first item
mylist[-1] β last item
mylist[2:6]
mylist[-5:-2]
mylist[4] = "BIKE"
mylist.append("A")
mylist.extend([1,2,3])
mylist.insert(1, "New")
mylist.remove("apple")
mylist.pop() # last item
mylist.sort()
mylist.reverse()
mylist.count("apple")
new = mylist.copy()
traincar = [['Raj',1], ['vacant',2]]
traincar[0][0] # Raj
Chapter 1: Artificial Intelligence β Basics and Project CycleChapter 2: Data and Problem ScopingChapter 3…
UNITβ1: Introduction to AI Project Cycle & AI EthicsCHAPTER 1- Artificial Intelligence: Basics and Project…
A complete teacher-made guide explaining the KVS Silchar Region question paper blueprint for Session Ending…
Let us discuss Page No. 213 I. Match the words in Column 1 with their…
Let us discuss Page No. 201 I. Complete the summary with an exact word from…
Let us discuss Page No. 187 I. Complete the table given below. An example has…