PCDS Tutors — Home • Online • Academic • Professional LearningServing 10+ launch cities • Expanding across India
Practical learning guideBeginner

Python: Tutorial, Projects & Course Syllabus

Python programming from fundamentals to automation, data and backend use cases.

Who this is for

Students, engineers and professionals

Before you start

Python 3 and basic lists/dictionaries.

Practical lesson

Summarise lesson attendance with Python

Use dictionaries for named fields and a loop for accumulation.

Separate calculation from printing so the function can be tested.

Set up your practice environment

Save as attendance.py and run python3 attendance.py.

python
def attendance(rows):
    result = {}
    for row in rows:
        name = row['student']
        result.setdefault(name, 0)
        if row['present']:
            result[name] += 1
    return result

rows = [{'student':'A', 'present': True},
        {'student':'B', 'present': False},
        {'student':'A', 'present': True}]
assert attendance([]) == {}
assert attendance(rows) == {'A': 2, 'B': 0}
print(attendance(rows))

Expected result

{'A': 2, 'B': 0}

Walk through the example

  1. setdefault initializes a missing count without overwriting an existing one.
  2. Only present lessons increment the count.
  3. Assertions verify the function for both populated and empty input.

Common mistake

The string "False" is truthy in Python. Parse CSV booleans explicitly.

Try it yourself

Return both total scheduled sessions and attended sessions for each student.

Reveal suggested solution

Initialize result[name] to {"scheduled":0,"attended":0}, increment scheduled for every row and attended only when present.

Portfolio project brief

Read a synthetic CSV attendance file, validate rows and generate a weekly summary.

Acceptance criteria

  • Handle missing and invalid values.
  • Test duplicate and empty input.
  • Do not use real student data in public examples.

This is a project specification, not a completed downloadable project. Build and test it independently or with a mentor.

Quick self-test

Choose one answer per question, then check your score. No sign-in required.

1. What does setdefault do when the key exists?
2. Which value is truthy?

Complete learning roadmap

These are suggested course modules, not a claim that every module has a full tutorial on this site.

  1. 01Python fundamentals
  2. 02Functions & modules
  3. 03OOP
  4. 04Files & APIs
  5. 05Automation
  6. 06Project track: web/data/AI

Learning outcomes

  • Write Python programs
  • Automate tasks
  • Prepare for data/AI tracks

Continue with official documentation

Original PCDS learning material. Check the official documentation for your installed software version; these guides are not vendor-endorsed courses.

Python tutorial →

Need help learning Python?

Choose a city and describe your learning goal in the enquiry form. Mention Python, your current level and whether you prefer home or online learning. Tutor availability and pricing are subject to confirmation.

Browse Python tutoring options in Mira Road or select a city above.

Python Tutorial, Practical Project & Course Syllabus | PCDS Learning