10 Beginner Python Programs for Class 11 Students
After learning the basic concepts of Python, the best way to improve programming skills is through regular practice. Class 11 students can start with simple programs based on conditions, loops, strings, lists and dictionaries.
If you are learning Python for Class 11, you can also read our guide: Python Programming for Class 11 Students: What You Should Learn
1. Print Your Name
A simple program to start with is printing your name.
name = "Rahul" print(name)
2. Add Two Numbers
This program takes two numbers and calculates their sum.
a = 10
b = 20
sum = a + b
print("Sum =", sum)
3. Check Whether a Number is Even or Odd
The modulus operator can be used to check whether a number is divisible by 2.
num = 15
if num % 2 == 0:
print("Even")
else:
print("Odd")
4. Find the Greater Number
Use an if-else statement to compare two numbers.
a = 25
b = 18
if a > b:
print("A is greater")
else:
print("B is greater")
5. Print Numbers from 1 to 10
A for loop can be used when you want to repeat a task multiple times.
for i in range(1, 11):
print(i)
6. Find the Sum of Numbers from 1 to 10
This program uses a loop to calculate the total of numbers from 1 to 10.
total = 0
for i in range(1, 11):
total = total + i
print("Total =", total)
7. Count Characters in a String
Python provides the len() function to find the length of a string.
name = "Python"
print("Characters =", len(name))
8. Find the Largest Number in a List
Lists are an important Python data type. The max() function can be used to find the largest value.
numbers = [10, 25, 7, 40, 18]
largest = max(numbers)
print("Largest =", largest)
9. Display Items from a Tuple
A tuple can store multiple values. You can use a loop to access its items.
subjects = ("Python", "Math", "English")
for subject in subjects:
print(subject)
10. Display Values from a Dictionary
Dictionaries store data in key-value pairs.
student = {
"name": "Rahul",
"class": 11,
"city": "Bareilly"
}
print(student["name"])
print(student["class"])
print(student["city"])
Practice These Programs Yourself
Instead of only reading these examples, type each program yourself and run it. Then try changing the values and modifying the programs.
For example, after writing the even-odd program, try checking whether a number is positive, negative or zero.
What's Next?
Once you are comfortable with these basic programs, you can move towards more practice with strings, lists, tuples, dictionaries and problem-solving programs.
Also Read: Python Variables Explained with Simple Examples
Learn Python Through Practical Coding
Students can learn Python concepts through regular coding practice and practical programming exercises.
Comments
Post a Comment