Lists in Python
Python Lists
What are Lists in Python?
Lists in Python means a list is an ordered and changeable collection. It is commonly used to store multiple values in one variable.
In real programs, this topic helps in storing multiple marks or names. Learn the idea first, then type the program yourself and compare the output.
| Point | Details |
|---|---|
| Course Area | Core Python Basic programming concepts used to write Python programs. |
| Main Use | storing multiple marks or names |
| Example File | lists.py |
| Practice Focus | Run, change values, and explain the output line by line. |
Why should you learn this?
- It is useful for storing multiple marks or names.
- It connects with finding highest/lowest/average.
- It improves your ability to read, write and debug Python programs.
Important Terms
These terms are used directly in this lesson. Understand them before memorising the code.
| Term | Meaning |
|---|---|
| ordered | Collection keeps elements in a defined sequence. |
| mutable | Object can be changed after creation. |
| append | List method used to add an item at the end. |
| remove | List method used to delete a matching item. |
| indexing | Accessing one element by its position number. |
Syntax / Basic Pattern
The simple pattern is: prepare data, apply the concept, then show the result.
marks = [78, 85, 91, 66]
marks.append(88)
marks[0] = 80
print(marks)
print("Highest:", max(marks))
print("Average:", sum(marks) / len(marks))Complete Example Program
marks = [78, 85, 91, 66]
marks.append(88)
marks[0] = 80
print(marks)
print("Highest:", max(marks))
print("Average:", sum(marks) / len(marks))Expected Output
Program Explanation
marks = [78, 85, 91, 66]stores a value in marks.marks.append(88)performs the next step of the program logic.marks[0] = 80stores a value in marks[0].print(marks)displays information or calculated result on the screen.print("Highest:", max(marks))displays information or calculated result on the screen.print("Average:", sum(marks) / len(marks))displays information or calculated result on the screen.
Where will you use it?
- Storing multiple marks or names.
- Finding highest/lowest/average.
- Processing values one by one.
Common Mistakes
- Writing code with wrong indentation.
- Using input() value directly in calculations without converting it to int or float.
- Using unclear variable names that make the program difficult to understand.
Practice Tasks
- Type the program in
lists.pyand run it. - Change input values or sample data and observe the new output.
- Create one example related to storing multiple marks or names.
- Write 5 lines explaining the logic in your own words.
Summary
Lists in Python is not a theory-only topic. You should be able to explain the meaning, write the example, run it successfully, and use it in a small practical program.
Python Lists क्या है?
Python Lists ka matlab hai: A list is an ordered and changeable collection. It is commonly used to store multiple values in one variable. Simple words me, ye topic practical Python programs likhne me direct use hota hai.
Is topic ko sirf definition ke liye nahi, balki storing multiple marks or names jaise real examples ke liye practice karein.
यह क्यों सीखना जरूरी है?
- Ye storing multiple marks or names me kaam aata hai.
- Ye finding highest/lowest/average se bhi connected hai.
- Isse aap code ka output aur errors better samajh paate hain.
Important Terms
| Term | Meaning |
|---|---|
| ordered | Collection keeps elements in a defined sequence. |
| mutable | Object can be changed after creation. |
| append | List method used to add an item at the end. |
| remove | List method used to delete a matching item. |
| indexing | Accessing one element by its position number. |
Syntax / Basic Pattern
Basic idea: pehle data तैयार करें, phir Python logic apply करें, aur finally result display करें.
marks = [78, 85, 91, 66]
marks.append(88)
marks[0] = 80
print(marks)
print("Highest:", max(marks))
print("Average:", sum(marks) / len(marks))Complete Example Program
marks = [78, 85, 91, 66]
marks.append(88)
marks[0] = 80
print(marks)
print("Highest:", max(marks))
print("Average:", sum(marks) / len(marks))Expected Output
Program Explanation
marks = [78, 85, 91, 66]stores a value in marks.marks.append(88)performs the next step of the program logic.marks[0] = 80stores a value in marks[0].print(marks)displays information or calculated result on the screen.print("Highest:", max(marks))displays information or calculated result on the screen.print("Average:", sum(marks) / len(marks))displays information or calculated result on the screen.
Practical Uses
- Storing multiple marks or names.
- Finding highest/lowest/average.
- Processing values one by one.
Common Mistakes
- Writing code with wrong indentation.
- Using input() value directly in calculations without converting it to int or float.
- Using unclear variable names that make the program difficult to understand.
Practice Tasks
- Program ko
lists.pyfile me type karke run karein. - Values change karke output compare karein.
- storing multiple marks or names par ek छोटा example banayen.
- Logic ko apne words me 5 lines me likhein.
सारांश
Lists in Python ko tab complete maanenge jab aap iska meaning, example, output aur practical use clearly explain kar saken.