0% found this document useful (0 votes)
26 views5 pages

Python Basics: Comprehensive Guide

The document provides comprehensive notes on Python basics, covering topics such as variables, data types, operators, control flow, loops, functions, and data structures like lists and dictionaries. It includes practical examples and a mini project for creating a student database. Additionally, it outlines next steps for further learning in Python, including file handling and libraries like NumPy and Pandas.
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)
26 views5 pages

Python Basics: Comprehensive Guide

The document provides comprehensive notes on Python basics, covering topics such as variables, data types, operators, control flow, loops, functions, and data structures like lists and dictionaries. It includes practical examples and a mini project for creating a student database. Additionally, it outlines next steps for further learning in Python, including file handling and libraries like NumPy and Pandas.
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 Basics – Complete Notes

TABLE OF CONTENTS

1. Variables

2. Input & Output

3. Data Types & Type Conversion

4. Arithmetic Operators

5. If–Else & Conditions

6. Loops

7. Modulus Operator

8. Accumulator Pattern

9. Lists

10. List Operations

11. Functions

12. Dictionaries

13. Looping Through Dictionaries

14. List of Dictionaries

15. Mini Project: Student Database

16. Next Steps in Python Learning

--------------------------------------------

1. VARIABLES

A variable stores a value. Example:

name = "Sanjai"

age = 19

--------------------------------------------

2. INPUT & OUTPUT

Input is taken as a string.


food = input("Enter food: ")

print(food)

--------------------------------------------

3. TYPE CONVERSION

num1 = int(input("Enter number: "))

num2 = int(input("Enter number: "))

print(num1 + num2)

Common mistake:

int(num1) # does nothing unless assigned

--------------------------------------------

4. ARITHMETIC OPERATORS

+, -, *, /, //, %

--------------------------------------------

5. IF–ELIF–ELSE

if A > B:

print("A is bigger")

elif A == B:

print("Equal")

else:

print("B is bigger")

--------------------------------------------

6. LOOPS

For Loop:

for i in range(5):

print(i)
While Loop:

i=1

while i <= 5:

print(i)

i += 1

range():

range(n)

range(start, stop)

range(start, stop, step)

--------------------------------------------

7. MODULUS OPERATOR (%)

Used for even/odd:

if i % 2 == 0: print("even")

--------------------------------------------

8. SUM USING LOOP (ACCUMULATOR)

total = 0

for i in range(1, 11):

total += i

print(total)

--------------------------------------------

9. LISTS

colors = ["red", "green", "blue"]

[Link]("yellow")

Loop:

for c in colors:

print(c)
--------------------------------------------

10. FUNCTIONS

def greet():

print("Hello")

With parameters:

def square(n):

return n*n

--------------------------------------------

11. DICTIONARIES

student = {"name": "Sanjai", "age": 19}

Access:

student["name"]

Update:

student["age"] = 20

--------------------------------------------

12. LOOPING DICTIONARIES

for k in student: print(k)

for v in [Link](): print(v)

for k,v in [Link](): print(k, v)

--------------------------------------------

13. LIST OF DICTIONARIES

students = [

{"name": "A", "age": 10},

{"name": "B", "age": 11}

]
--------------------------------------------

14. MINI PROJECT — STUDENT DATABASE

students = []

count = int(input("How many? "))

for i in range(count):

name = input("Enter name: ")

age = int(input("Enter age: "))

branch = input("Enter branch: ")

student_data = {"name": name, "age": age, "branch": branch}

[Link](student_data)

print(students)

--------------------------------------------

15. NEXT STEPS IN PYTHON LEARNING

- File handling

- JSON

- Classes & OOP

- NumPy, Pandas

- Small projects

You might also like