0% found this document useful (0 votes)
19 views3 pages

Basic Python Revision Notes

This document provides a concise overview of basic Python programming concepts, including syntax, data types, operators, control structures, functions, and data structures. It also covers exception handling, file handling, modules, object-oriented programming, list comprehension, and useful functions. Additionally, it touches on the use of virtual environments for managing project dependencies.

Uploaded by

jaintanish281105
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)
19 views3 pages

Basic Python Revision Notes

This document provides a concise overview of basic Python programming concepts, including syntax, data types, operators, control structures, functions, and data structures. It also covers exception handling, file handling, modules, object-oriented programming, list comprehension, and useful functions. Additionally, it touches on the use of virtual environments for managing project dependencies.

Uploaded by

jaintanish281105
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/ 3

Basic Python - One Night Exam Revision Notes

1. Introduction to Python
- High-level, interpreted, object-oriented programming language.
- Dynamically typed and easy to learn.

2. Basic Syntax
- Case-sensitive, indentation is crucial.
- Comments: # for single line, ''' ''' or for multi-line.

3. Variables and Data Types


- No need to declare type explicitly.
- Types: int, float, str, bool, list, tuple, dict, set.

4. Operators
- Arithmetic: +, -, *, /, %, //, **
- Comparison: ==, !=, >, <, >=, <=
- Logical: and, or, not

5. Control Structures
- if, elif, else
- while loop
- for loop (with range or iterable)

6. Functions
- Defined with def keyword.
```python
def greet(name):
return "Hello " + name
```

7. Data Structures
- List: Mutable ordered collection.
- Tuple: Immutable ordered collection.
- Set: Unordered unique elements.
- Dictionary: Key-value pairs.

8. String Operations
- Concatenation, slicing, methods (upper(), lower(), split(), join(), etc.)

9. Exception Handling
- try, except, finally
```python
try:
x = 10 / 0
except ZeroDivisionError:
print("Can't divide by zero.")
```

10. File Handling


```python
with open("file.txt", "r") as f:
content = f.read()
```

11. Modules and Libraries


- Import standard or third-party modules using import.
- Popular libraries: math, random, os, sys

12. Object-Oriented Programming


- Class, object, __init__, self, methods
```python
class Person:
def __init__(self, name):
self.name = name
```

13. List Comprehension


- Short syntax for creating lists.
```python
squares = [x**2 for x in range(10)]
```

14. Useful Functions


- len(), type(), range(), input(), print(), int(), str()

15. Virtual Environments (Advanced)


- Use venv to manage dependencies separately for projects.

You might also like