🟢 Beginner  ·  Lesson 12

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.

💡 At a Glance
PointDetails
Course AreaCore Python
Basic programming concepts used to write Python programs.
Main Usestoring multiple marks or names
Example Filelists.py
Practice FocusRun, 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.

TermMeaning
orderedCollection keeps elements in a defined sequence.
mutableObject can be changed after creation.
appendList method used to add an item at the end.
removeList method used to delete a matching item.
indexingAccessing one element by its position number.

Syntax / Basic Pattern

The simple pattern is: prepare data, apply the concept, then show the result.

Basic Pattern
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

Python – lists.py
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

[80, 85, 91, 66, 88] Highest: 91 Average: 82.0

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] = 80 stores 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

  1. Type the program in lists.py and run it.
  2. Change input values or sample data and observe the new output.
  3. Create one example related to storing multiple marks or names.
  4. 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

TermMeaning
orderedCollection keeps elements in a defined sequence.
mutableObject can be changed after creation.
appendList method used to add an item at the end.
removeList method used to delete a matching item.
indexingAccessing one element by its position number.

Syntax / Basic Pattern

Basic idea: pehle data तैयार करें, phir Python logic apply करें, aur finally result display करें.

Basic Pattern
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

Python – lists.py
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

[80, 85, 91, 66, 88] Highest: 91 Average: 82.0

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] = 80 stores 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

  1. Program ko lists.py file me type karke run karein.
  2. Values change karke output compare karein.
  3. storing multiple marks or names par ek छोटा example banayen.
  4. 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.

← Back to Python Tutorial