[Go to site: main page, start]

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

Python Basic Notes

This document provides basic notes on Python programming, covering its introduction, syntax, variables, data types, operators, conditional statements, loops, functions, lists, dictionaries, comments, input/output, module importing, file handling, and exception handling. It emphasizes the importance of indentation and provides examples for various concepts. Overall, it serves as a concise guide for beginners to understand fundamental Python programming principles.

Uploaded by

11 Aniket 10A
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)
5 views2 pages

Python Basic Notes

This document provides basic notes on Python programming, covering its introduction, syntax, variables, data types, operators, conditional statements, loops, functions, lists, dictionaries, comments, input/output, module importing, file handling, and exception handling. It emphasizes the importance of indentation and provides examples for various concepts. Overall, it serves as a concise guide for beginners to understand fundamental Python programming principles.

Uploaded by

11 Aniket 10A
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 Basic Notes

1. Introduction to Python:
- Python is a high-level, interpreted programming language.
- It is easy to learn and widely used in web development, data science, AI, and more.
2. Python Syntax Basics:
- Statements are written line by line.
- Indentation is important; it defines code blocks.
3. Variables:
- Used to store data values.
- Example: x = 5, name = 'John'
4. Data Types:
- int: Integer numbers (e.g., 5, -2)
- float: Decimal numbers (e.g., 3.14)
- str: Strings (e.g., 'Hello')
- bool: Boolean values (True or False)
5. Operators:
- Arithmetic: +, -, *, /, %, **, //
- Comparison: ==, !=, >, <, >=, <=
- Logical: and, or, not
6. Conditional Statements:
if condition:
# code block
elif condition:
# code block
else:
# code block
7. Loops:
- for loop: for i in range(5):
print(i)
- while loop: while condition:
# code block
8. Functions:
def greet():
print('Hello!')
9. Lists:
- Example: fruits = ['apple', 'banana', 'cherry']
- Access: fruits[0] → 'apple'
10. Dictionaries:
- Example: person = {'name': 'John', 'age': 25}
- Access: person['name'] → 'John'
11. Comments:
- Single-line: # This is a comment
- Multi-line: ''' This is a multi-line comment '''
12. Input and Output:
- input(): Takes user input.
- print(): Displays output.
13. Importing Modules:
- Example: import math
- print([Link](16)) → 4.0
14. File Handling:
- f = open('[Link]', 'r') → Read mode
- f = open('[Link]', 'w') → Write mode
15. Exception Handling:
try:
# risky code
except Exception as e:
print(e)

You might also like