Kit Library / Computer Science / Programming Fundamentals

⚡ Topic Learning Kit

Python Programming — C20 DCME Fifth Semester (Board Exam Scope)

English 18 leveled MCQs 35 flashcards 9 games Free

Shared by a Veda learner · Generated with Veda AI

Veda Bites

The whole idea, one bite at a time

Veda Bites are swipeable micro-lessons — each one teaches exactly one idea. The bites below come from this kit — swipe through them in the app.

💡 Key Idea

Python's Core Building Blocks

Master these 7 pillars to crack the paper.

The C20 Python syllabus is built on seven interconnected pillars — each appearing in the board exam.

↳ Every board question maps to one of these seven pillars — identify the pillar, recall its syntax, and answer confidently.

📖 Definition

What Is a Variable?

Variables are named boxes for your data.

↳ In Python, a variable is created the moment you assign a value — no separate declaration keyword is needed.

📖 Definition

What Is an Operator?

Operators are the verbs of programming.

↳ Operators are classified by the job they do — arithmetic for math, relational for comparison, logical for combining conditions.

⚖️ Comparison

break vs continue vs assert

Three keywords, three different exits.

↳ `break` kills the loop, `continue` skips one round, `assert` checks a condition and crashes if it fails.

💻 Code Example

Skipping Elements with continue

Skip what you don't need — elegantly.

The `continue` statement skips printing multiples of 3, demonstrating how to filter elements inside a loop.

↳ `continue` is the cleanest way to skip specific elements without breaking the entire loop.

📖 Definition

What Is range()?

range() generates numbers on demand.

↳ `range()` never includes the stop value — remember this to avoid off-by-one errors.

📖 Definition

Python Package

Packages are folders full of modules.

↳ A package is a collection of modules — it helps organize large programs into manageable folders.

⚖️ Comparison

List vs Tuple vs Dictionary vs Set

Four containers, four superpowers.

↳ Choose list for ordered changeable data, tuple for fixed data, dictionary for key-value pairs, and set for unique unordered items.

📖 Definition

Cloning a List

Copy smartly — don't share the same list.

↳ `new_list = old_list` creates a reference, not a clone — use `.copy()` or `[:]` for a true copy.

📖 Definition

Mutability Explained

Some objects can change, some can't.

↳ Mutability decides whether you can modify an object in place — lists yes, tuples no.

📖 Definition

Classes and Objects

Classes are blueprints, objects are buildings.

↳ A class defines what an object can do; an object is the actual thing that does it.

💻 Code Example

Object and Data Hiding Example

Protect your data with double underscores.

The `__marks` attribute is hidden — accessing it directly from outside the class raises an `AttributeError`.

↳ Prefixing an attribute with `__` hides it from outside access — this is Python's data hiding.

📖 Definition

Exception Handling

Catch errors before they crash you.

↳ Wrap risky code in `try`, handle errors in `except`, and clean up in `finally`.

⚙️ Process

Writing and Running Code in Python IDLE

From blank screen to running program.

↳ IDLE gives you two windows — the editor for writing code and the shell for seeing output.

💻 Code Example

Count Letters and Digits in a String

The Part-C question solved in 6 lines.

This uses `isalpha()` and `isdigit()` to classify each character — exactly the logic expected in the board's Part-C question.

↳ Loop through each character, use `isalpha()` and `isdigit()` to count — this is the standard board solution.

⚠️ Common Mistake

Copying a List vs Referencing It

One equals sign can ruin your data.

↳ `=` creates a reference, not a clone — always use `.copy()` or slicing when you need an independent list.

⚠️ Common Mistake

range() Does Not Include the Stop Value

The most common off-by-one error.

↳ `range(start, stop)` always excludes `stop` — add 1 to include it.

🎯 Exam Tip

Board Exam Strategy for Python

Score maximum with smart answering.

↳ Match your answer depth to the marks — brief for Part-A, comprehensive with programs for Part-B and Part-C.

🧠 Memory Trick

Remember the Four Data Structures

One sentence locks all four in.

Lists Take Duplicates Sometimes — List (ordered, mutable), Tuple (ordered, immutable), Dictionary (key-value), Set (unique, unordered).

↳ L-T-D-S: List, Tuple, Dictionary, Set — ordered changeable, ordered fixed, key-value, unique.

❓ Did You Know

Python Was Named After a Comedy Show

Not the snake — the comedy troupe.

Guido van Rossum named Python after Monty Python's Flying Circus, not the snake. He was a fan of the British comedy show.

↳ Python's name comes from a comedy show — a fun fact that sticks.

Smart notes

What you'll study, topic by topic

1

Python Programming — C20 DCME Fifth Semester (Board Exam Scope)

15 min

This topic covers the core Python programming concepts prescribed for the C20 DCME Fifth Semester Board Examination — variables, operators, control flow, data structures, functions, OOP, and exception handling. It maps d…

  • A variable in Python is a name that refers to a value in memory; no explicit type declaration is needed.
  • Python uses dynamic typing, so the same name can later refer to a value of a different type.
  • Declaration and initialization in Python usually happen together in a single assignment statement.

Full explanation, worked examples & memory tricks in the app

Leveled MCQ practice

Try the smart MCQs from this kit

All 18 questions, laddered from warm-up to topper-level, each with its answer and the reasoning behind it.

Warm-up · 7 questions

Q1. In Python, what is a variable?

Beginner
A A fixed box that stores only integers
B A reserved keyword for declaring types
C A name that refers to a value in memory
D A function that prints values
Show the answer

C · A name that refers to a value in memory

A Python variable is a name bound to a value in memory. No type declaration is required, and the name can later refer to a value of a different type.

Q2. Which statement about Python's typing is correct?

Beginner
A A name can never refer to a different type later
B Every variable must be declared with a type first
C Types are decided by the file extension
D Types are determined at runtime, not declared in advance
Show the answer

D · Types are determined at runtime, not declared in advance

Python uses dynamic typing: the type of a value is determined at runtime, so the same name can later refer to a value of a different type.

Q3. A student writes `x = 10` and then `x = "hello"` in the same program. What happens?

Beginner
A It raises a type error immediately
B `x` keeps the integer 10 and ignores the string
C Python deletes `x` and creates a new variable
D It runs fine; `x` now refers to a string
Show the answer

D · It runs fine; `x` now refers to a string

Because of dynamic typing, reassigning `x` to a string is perfectly legal. The name simply points to a new value.

Q4. Which operator assigns a value rather than comparing two values?

Beginner
A `=`
B `!=`
C `is`
D `==`
Show the answer

A · `=`

`=` is the assignment operator. `==` compares two values for equality, and `!=` and `is` are also comparison-style operators.

Q5. Which family does the `in` operator belong to?

Beginner
A Membership
B Arithmetic
C Assignment
D Identity
Show the answer

A · Membership

`in` and `not in` are membership operators; they check whether a value is present in a sequence or collection.

Q6. What sequence does `range(5)` generate?

Beginner
A 0, 1, 2, 3, 4
B 0, 1, 2, 3, 4, 5
C 1, 2, 3, 4, 5
D 5, 4, 3, 2, 1
Show the answer

A · 0, 1, 2, 3, 4

`range(5)` starts at 0 and stops before 5, producing 0, 1, 2, 3, 4.

Q7. Python uses dynamic typing, so variable types are determined at runtime rather than declared in advance.

Beginner
A True
B False
Show the answer

A · True

Python uses dynamic typing, so variable types are determined at runtime rather than declared in advance.

Building up · 6 questions

Q8. Which loop is best when you must repeat a block until a condition becomes false?

Intermediate
A A `try` block
B A single `if` statement
C A `for` loop over a list
D A `while` loop
Show the answer

D · A `while` loop

A `while` loop repeats as long as its condition stays true, which suits condition-driven repetition. A `for` loop is meant for iterating over a sequence.

Q9. Inside a loop, you want to skip even numbers and keep processing the rest. Which statement fits?

Intermediate
A `assert`
B `continue`
C `pass`
D `break`
Show the answer

B · `continue`

`continue` skips the rest of the current iteration and moves to the next one, so even numbers are skipped while the loop keeps running.

Q10. What does `*args` collect inside a function?

Intermediate
A Default values for all parameters
B The function's return values
C Extra positional arguments, as a tuple
D Extra keyword arguments, as a dictionary
Show the answer

C · Extra positional arguments, as a tuple

`*args` gathers extra positional arguments into a tuple. It is `**kwargs` that gathers extra keyword arguments into a dictionary.

Q11. Which pair of collections is ordered and allows duplicates?

Intermediate
A Lists and tuples
B Sets and dictionaries
C Sets and tuples
D Dictionaries and lists
Show the answer

A · Lists and tuples

Lists and tuples are both ordered and allow duplicate values. Sets are unordered with no duplicates, and dictionary keys must be unique.

Q12. A list `a` exists. Which line creates an independent copy so that changing `b` leaves `a` untouched?

Intermediate
A `b = a[:]`
B `b == a`
C `b = a`
D `b = a is a`
Show the answer

A · `b = a[:]`

`b = a[:]` (or `b = list(a)`) makes an independent copy. `b = a` only creates a second name for the same list, so changes show up in both.

Q13. Which statement about strings is correct?

Intermediate
A Strings are unordered and store no duplicates
B Strings are immutable sequences of characters
C Strings are mutable and can be edited in place
D Strings can only hold digits
Show the answer

B · Strings are immutable sequences of characters

A string is an immutable sequence of characters. Methods like `upper()` return new strings rather than changing the original.

Topper level · 5 questions

Q14. Which statement about `break` and `continue` is correct?

Advanced
A Both restart the loop from the beginning
B `break` skips one iteration; `continue` exits the loop
C Both exit the loop immediately
D `break` exits the loop; `continue` skips to the next iteration
Show the answer

D · `break` exits the loop; `continue` skips to the next iteration

`break` leaves the loop entirely, while `continue` abandons only the current iteration and proceeds to the next one.

Q15. A program must respond gracefully when a user enters text where a number was expected. Which structure should it use?

Advanced
A `try` with `except` and `finally`
B An `assert` statement alone
C A `for` loop over `range()`
D A `while` loop with `break`
Show the answer

A · `try` with `except` and `finally`

Exception handling with `try`, `except`, and `finally` lets the program catch the runtime error and continue instead of crashing. `assert` only raises an error; it does not handle one.

Q16. Which statement about data hiding in Python is correct?

Advanced
A Only functions can hide data, not classes
B A leading underscore signals restricted access by convention
C Data hiding requires declaring every attribute as `public`
D Python blocks all access to attributes starting with `_`
Show the answer

B · A leading underscore signals restricted access by convention

Python uses naming conventions: `_name` signals internal use and `__name` triggers name mangling. The restriction is by convention and mangling, not a hard access block.

Q17. You are tasked with writing a function that takes a list of integers and returns a new list containing only the odd integers, while also handling any potential errors gracefully. Which implementation correctly achieves this?

Advanced
A ```python def filter_odds(numbers): odds = [] for n in numbers: if n % 2 == 0: continue odds.append(n) return odds ```
B ```python def filter_odds(numbers): odds = [] for n in numbers: if isinstance(n, int): if n % 2 != 0: odds.append(n) return odds ```
C ```python def filter_odds(numbers): return [n for n in numbers if n % 2 != 0] ```
D ```python def filter_odds(numbers): return [n for n in numbers if n % 2 == 0] ```
Show the answer

A · ```python def filter_odds(numbers): odds = [] for n in numbers: if n % 2 == 0: continue odds.append(n) return odds ```

The correct option uses a `for` loop with a `continue` statement to skip even numbers and append only odd integers to the list. This effectively filters out the even numbers.

Q18. Given the following class definition, what will be the output of the code snippet when executed? ```python class BankAccount: def __init__(self, balance): self.__balance = balance def deposit(self, amount): self.__balance += amount def get_balance(self): return self.__balance account = BankAccount(100) account.deposit(50) print(account.get_balance()) ```

Advanced
A 50
B Error: 'BankAccount' object has no attribute '__balance'
C 100
D 150
Show the answer

D · 150

The output is 150 because the `deposit` method successfully adds 50 to the initial balance of 100, demonstrating correct encapsulation and method functionality in the class.

Flashcards

Tap a card to flip it

35 flashcards in this kit — the app reviews them with spaced repetition so the right card returns on the right day.

Learning games

Play your way through this kit

Every game is built from this kit's own content — scores feed your mastery, so playing counts as studying.

🎮

Word Match

Built from this kit's own content

🎮

True False

Built from this kit's own content

🎮

Memory Match

Built from this kit's own content

🎮

Flashcard Battle

Built from this kit's own content

🎮

Speed Quiz

Built from this kit's own content

🎮

Guess Term

Built from this kit's own content

🎮

Sequence Builder

Built from this kit's own content

🎮

Categorization

Built from this kit's own content

🎮

Revision Battle

Built from this kit's own content

Playable in the app

Study it properly — free, in the app

The full Veda Bites deck, complete notes, spaced-repetition flashcards, leveled MCQs, tests and games for this kit — plus Daily Facts and the Arena, every day.