Introduction to Python Programming – Class 10 Computer Science
Learn Python programming basics: variables, data types, operators, input/output, and control flow for CBSE Class 10 Computer Science.
Introduction to Python Programming
Python is a high-level, interpreted, general-purpose programming language created by Guido van Rossum in 1991. It is known for its simple syntax, readability, and versatility. Python is the recommended language for CBSE Class 10 Computer Science.
Why Python?
- Easy to learn and read (close to English)
- Free and open-source
- Used in web development, AI, data science, automation, and more
- Extensive library support
Variables and Data Types
A variable is a name that refers to a value stored in memory. Python is dynamically typed — you don't need to declare the type.
name = "SixBytes" # str (string) age = 15 # int (integer) marks = 95.5 # float (decimal) is_passed = True # bool (boolean)
Operators
| Type | Operators | Example |
|---|---|---|
| Arithmetic | +, -, *, /, //, %, ** | 5 ** 2 = 25, 7 // 2 = 3 |
| Comparison | ==, !=, >, <, >=, <= | 5 > 3 → True |
| Logical | and, or, not | True and False → False |
| Assignment | =, +=, -=, *=, /= | x += 5 means x = x + 5 |
Input and Output
# Output
print("Hello, SixBytes!")
# Input (always returns a string)
name = input("Enter your name: ")
age = int(input("Enter your age: ")) # Convert to int
print(f"Hello {name}, you are {age} years old!")
Conditional Statements
marks = int(input("Enter marks: "))
if marks >= 90:
print("Grade: A+")
elif marks >= 75:
print("Grade: A")
elif marks >= 60:
print("Grade: B")
else:
print("Grade: C")
Loops
for loop — iterates over a sequence:
for i in range(1, 11):
print(i, end=" ")
# Output: 1 2 3 4 5 6 7 8 9 10
while loop — repeats while a condition is True:
count = 1
while count <= 5:
print("SixBytes", count)
count += 1
Strings
s = "SixBytes Institute"
print(len(s)) # 19
print(s[0]) # S
print(s[-1]) # e
print(s[0:3]) # Six (slicing)
print(s.upper()) # SIXBYTES INSTITUTE
print(s.lower()) # sixbytes institute
print(s.replace("Institute", "Academy")) # SixBytes Academy
Lists
subjects = ["Maths", "Science", "English"]
subjects.append("Hindi")
subjects.remove("English")
print(subjects) # ['Maths', 'Science', 'Hindi']
print(len(subjects)) # 3
Reference: NCERT Computer Science Textbook for Class 10; Sumita Arora Python for Class 10; Let Us Python by Yashavant Kanetkar.
Indexed Topics & Examination Keywords
Aiming for 95%+ in CBSE / ICSE Board & Competitive Exams?
Join daily batches at SixBytes Institute for personalized mentoring, one-on-one doubt solving, and structured mock test series for Classes 9–12 & NDA.
