0% found this document useful (0 votes)
4 views6 pages

Pyth 11th Rev

Chapter 1 covers the basics of Python, including its definition, keywords, identifiers, variables, data types, input/output methods, operators, control statements, loops, strings, and lists. It provides examples and practice questions to reinforce understanding of these concepts. A summary cheat-sheet is included for quick reference on key functions and operations.

Uploaded by

patelanushka466
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)
4 views6 pages

Pyth 11th Rev

Chapter 1 covers the basics of Python, including its definition, keywords, identifiers, variables, data types, input/output methods, operators, control statements, loops, strings, and lists. It provides examples and practice questions to reinforce understanding of these concepts. A summary cheat-sheet is included for quick reference on key functions and operations.

Uploaded by

patelanushka466
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/ 6

Perfect!

Let's now begin a complete and structured revision of Chapter 1: Python Basics (Class
11 revision) — which is essential for your Class 12 Computer Science foundation.

Chapter 1: Python Basics – Full Revision

1. What is Python?
Python is a high-level, interpreted, general-purpose programming language known for its
readability and simplicity.

2. Python Keywords

Reserved words you cannot use as identifiers

Examples: if, else, for, while, def, True, False, return, and, or, etc.

3. Identifiers

Names used for variables, functions, etc.

Must start with a letter or underscore (not digits)

Cannot use spaces or special characters


valid = _num1
invalid = 1num #

4. Variables and Data Types


Data Type Example
Integer a = 10
Float b = 3.14
String name = "Ravi"
Boolean flag = True

You can check the data type using:

print(type(a))

5. Input and Output


# Input
name = input("Enter your name: ")

# Output
print("Hello", name)

input() always returns a string. Use int(), float() to convert.

num = int(input("Enter number: "))

6. Operators
Type Example
Arithmetic +, -, *, /, %, **
Assignment =, +=, -=
Comparison ==, !=, <, >
Logical and, or, not
Membership in, not in
Identity is, is not

7. Control Statements
If-Else Statement
x=5
if x > 0:
print("Positive")
else:
print("Non-positive")

Elif Statement
n = int(input("Enter number: "))
if n > 0:
print("Positive")
elif n == 0:
print("Zero")
else:
print("Negative")

8. Loops
For Loop (with range)
for i in range(1, 6):
print(i)

While Loop
x=1
while x <= 5:
print(x)
x += 1
9. Strings Basics
s = "Python"

print(s[0]) #P
print(s[-1]) #n
print(s[1:4]) # yth
print(len(s)) #6

String Methods:
s.lower(), s.upper(), s.isalpha(), s.isdigit(), s.replace("P", "J")

10. List Basics


lst = [10, 20, 30]

lst.append(40)
lst.remove(20)
print(lst[1]) # 30
print(len(lst)) #3

Example Practice Questions

Q1. Predict the output:


a = 10
b=5
print(a + b * 2)

Output: 20
Because multiplication happens before addition.

Q2. Write a program to check if a number is even.


num = int(input("Enter number: "))
if num % 2 == 0:
print("Even")
else:
print("Odd")

Q3. What will this print?


x = "Python"
print(x[1:4])

Output: yth

Summary Cheat-Sheet

input() Takes string input

int(), float() Convert to number

if-elif-else Decision making

for, while Loops

print() Output

Strings, Lists Indexed and iterable

Let me know if you'd like:


A few short practice questions or

Shall I now remind you to start the flashcard quiz on File Handling, Functions, and Python
Basics?

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy