0% found this document useful (0 votes)
5 views14 pages

Python College Level

This document provides a comprehensive overview of Python programming, covering key concepts such as variables, data types, operators, control statements, loops, functions, data structures, string methods, file handling, object-oriented programming, modules, packages, and exception handling. It includes examples for each topic to illustrate the concepts. The notes serve as a foundational guide for teaching Python at a college level.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views14 pages

Python College Level

This document provides a comprehensive overview of Python programming, covering key concepts such as variables, data types, operators, control statements, loops, functions, data structures, string methods, file handling, object-oriented programming, modules, packages, and exception handling. It includes examples for each topic to illustrate the concepts. The notes serve as a foundational guide for teaching Python at a college level.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Python Notes - College Level

Complete Overview for Teaching


Introduction to Python
• Python is a high-level, interpreted language.
• Easy to read and used in web dev, AI, data
science.

• Example:
• print('Hello, World!')
Variables and Data Types
• Variables store data. Python is dynamically
typed.
• Types: int, float, str, bool.

• Example:
• x = 10
• name = 'Alice'
Operators
• Arithmetic: +, -, *, /
• Comparison: ==, !=, >
• Logical: and, or, not
• Assignment: =, +=, etc.
Control Statements
• Use if, else, elif for decisions.

• Example:
• age = 18
• if age >= 18:
• print('Adult')
Loops
• for and while used for repetition.

• Example:
• for i in range(5): print(i)
• while count < 5: print(count)
Functions
• Block of reusable code.

• Example:
• def greet(name): return 'Hello ' + name
Data Structures
• List: [1,2,3] | Tuple: (1,2)
• Set: {1,2} | Dict: {'a':1}
• Each has unique properties.
Strings & Methods
• Strings use methods
like .upper(), .lower(), .replace(), .split().

• Example:
• 'str'.upper()
File Handling
• Open files to read/write.

• Example:
• f = open('file.txt', 'w')
• f.write('Hello')
• f.close()
OOP in Python
• Use class & objects.

• Example:
• class Person:
• def __init__(self,name):
• self.name = name
Modules & Packages
• Modules: Python files
• Packages: Collection of modules

• Example:
• import math
• math.sqrt(16)
Exception Handling
• Use try-except to handle errors.

• Example:
• try:
• x = 1/0
• except:
• print('Error')
Sample Programs
• 1. Swap: x, y = y, x
• 2. Even/Odd:
• print('Even' if num % 2 == 0 else 'Odd')

You might also like