0% found this document useful (0 votes)
2 views

Python_Basics_Class11_Colored

The document provides an introduction to Python, highlighting its features such as simplicity, interpretability, and platform independence. It covers essential topics including syntax, data types, conditional statements, loops, functions, lists, tuples, and file handling. The conclusion emphasizes the importance of mastering these basics for future programming endeavors.

Uploaded by

drezhil2009
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python_Basics_Class11_Colored

The document provides an introduction to Python, highlighting its features such as simplicity, interpretability, and platform independence. It covers essential topics including syntax, data types, conditional statements, loops, functions, lists, tuples, and file handling. The conclusion emphasizes the importance of mastering these basics for future programming endeavors.

Uploaded by

drezhil2009
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Python Basics - Class 11 Computer Science

1. Introduction to Python

Python is a high-level, interpreted programming language that is simple and widely used in various
fields.

Features of Python:

- Simple & Easy to Learn


- Interpreted (Line-by-Line Execution)
- Dynamically Typed (No Type Declaration Needed)
- Open Source & Free
- Platform-Independent (Runs on Windows, macOS, and Linux)

2. Python Syntax and Variables

Python uses indentation instead of {} or ; like other languages.

Example:
if 10 > 5:
print('10 is greater than 5')

3. Data Types in Python

Common Data Types:


- int: Whole Numbers
- float: Decimal Numbers
- str: Text
- bool: True or False
- list: Ordered, Mutable Collection
- tuple: Ordered, Immutable Collection
- dict: Key-Value Pairs

4. Conditional Statements
Python Basics - Class 11 Computer Science

Example:
if age >= 18:
print('You are an adult.')
elif age >= 13:
print('You are a teenager.')
else:
print('You are a child.')

5. Loops in Python

For Loop Example:


for i in range(1, 6):
print(i)

While Loop Example:


x=1
while x <= 5:
print(x)
x += 1

6. Functions in Python

def greet(name):
print('Hello,', name)

greet('Alice')

7. Lists and Tuples

Lists (Mutable):
fruits = ['Apple', 'Banana', 'Cherry']
fruits.append('Mango')
Python Basics - Class 11 Computer Science

Tuples (Immutable):
colors = ('Red', 'Green', 'Blue')

8. File Handling in Python

Writing to a file:
with open('file.txt', 'w') as f:
f.write('Hello, Python!')

Reading from a file:


with open('file.txt', 'r') as f:
content = f.read()
print(content)

Conclusion

Python is an easy and powerful programming language. Mastering these basics will help you build
advanced programs in the future.

You might also like