Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
1 views

Python_Basics_Class11

The document provides an introduction to Python, highlighting its features such as simplicity, dynamic typing, and platform independence. It covers essential topics including syntax, data types, input/output, conditional statements, loops, functions, lists, tuples, dictionaries, and file handling. The conclusion emphasizes the importance of mastering these basics for Class 11 Computer Science.

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)
1 views

Python_Basics_Class11

The document provides an introduction to Python, highlighting its features such as simplicity, dynamic typing, and platform independence. It covers essential topics including syntax, data types, input/output, conditional statements, loops, functions, lists, tuples, dictionaries, and file handling. The conclusion emphasizes the importance of mastering these basics for Class 11 Computer Science.

Uploaded by

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

Python Basics - Class 11 Computer Science

1. Introduction to Python

Python is a high-level, interpreted programming language that is easy to learn and widely used in

various fields.

Features of Python:

- Simple & Easy to Learn

- Interpreted Language (line-by-line execution)

- Dynamically Typed (no need to declare variable types)

- 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")

Variables store values:

name = "Alice"

age = 16

height = 5.7
3. Data Types in Python

- int: 10, -5, 100 (whole numbers)

- float: 3.14, -2.5 (decimal numbers)

- str: "Hello", 'Python' (text)

- bool: True, False (boolean values)

- list: [1, 2, 3] (ordered, mutable collection)

- tuple: (4, 5, 6) (ordered, immutable collection)

- dict: {"name": "Bob", "age": 20} (key-value pairs)

4. Input and Output in Python

name = input("Enter your name: ")

print("Hello, " + name)

5. Conditional Statements

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

if age >= 18:

print("You are an adult.")

elif age >= 13:

print("You are a teenager.")

else:

print("You are a child.")

6. Loops in Python

For loop:

for i in range(1, 6):

print(i)
While loop:

x=1

while x <= 5:

print(x)

x += 1

7. Functions in Python

def greet(name):

print("Hello,", name)

greet("Alice")

8. Lists and Tuples

Lists (Mutable):

fruits = ["Apple", "Banana", "Cherry"]

fruits.append("Mango")

Tuples (Immutable):

colors = ("Red", "Green", "Blue")

9. Dictionaries (Key-Value Pairs)

student = {"name": "Alice", "age": 16, "class": "11th"}

print(student["name"])

10. 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 a powerful yet easy-to-learn programming language. Understanding the basics such as

syntax, variables, loops, functions, and file handling is essential for Class 11 Computer Science.

You might also like