Introduction to Computer Science YMT113 · Fall 2026 Assoc. Prof. Ferhat Uçar
09 Python · AI · SQL Monday, November 16, 2026

Python: The Same Ideas in a Tenth of the Lines

Every C program you wrote, rewritten in Python: no types to declare, no semicolons, no memory to free, and a library for everything. What you gain, what you give up, and how to learn any new language in a day.

CS50Week 6 · Python ReadCS50 notes; Python tutorial chapters 3–5 >_ Lab 7: C to Python

Before class · do this at home

Watch, read, then come

CS50x 2026 · Week 6: Python by David J. Malan. Watch the lecture on YouTube (you are also enrolled on edX), read the notes, skim the slides. Our lecture builds on it instead of repeating it.

  • Watch the lecture and, for each program, write the C version in your head first. The point of the week is the comparison.
  • Run python3 in your codespace terminal and type print("hello, world"). That is the whole setup.

Learning objectives

By the end of this week you can:

  • 1 Translate C programs with variables, conditions, loops and functions into Python.
  • 2 Use Python's built-in types: int, float, str, bool, list, dict, tuple, and explain dynamic typing.
  • 3 Handle input and exceptions with try/except and write input-validation loops.
  • 4 Import and use modules (random, csv, sys) and install packages with pip.
  • 5 Explain what an interpreter is, and why Python is slower than C but faster to write.
  • 6 Recognize when C is the right tool and when Python is.

★ the wow moment

CS50's speller: 200 lines of C become 20 lines of Python, and the Python version is still a hash table.

Python's set is a hash table written in C. Everything you built by hand in week 7 is one line: words = set(open('dictionary').read().split()). You did not waste week 7: you now know what that line costs and why it is fast. That is the difference between using a tool and understanding it, and it is the difference employers pay for.

Topics

  1. Hello, again: print("hello, world"); running with python3; no compile step; the interpreter.
  2. Types without declarations: int, float, str, bool; input() returns a string; int(input()); try/except ValueError.
  3. Conditions and loops: indentation instead of braces; if/elif/else; while; for i in range(n); for c in s.
  4. Lists and dicts: scores = [72, 73, 33], sum(scores) / len(scores); people = {"Carter": "+1-617"}; the hash table from week 7, built in.
  5. Functions and modules: def, default arguments, import random, from cs50 import get_int, sys.argv, sys.exit.
  6. Files: open, csv.reader, csv.DictWriter.
  7. C versus Python: overflow gone, floats still imprecise, speed 10–100× slower, and why that is usually fine.

Full notes are published before the lecture. The lab, Lab 7: C to Python, rewrites three earlier labs in Python and times the difference.

In industry

  • Python is the language of AI and data

    PyTorch, TensorFlow, pandas, scikit-learn: every machine-learning system is driven from Python, while the heavy lifting runs in C and CUDA underneath.

  • Glue and automation

    Most companies run thousands of Python scripts that move data, call APIs, generate reports and test systems. Knowing Python means never doing a repetitive task by hand again.

  • Interpreters and the speed trade-off

    Instagram, YouTube and Dropbox run on Python, and each has rewritten hot paths in C or Rust. Knowing both is the actual industry skill.

  • pip and the supply chain

    A one-line install pulls code written by strangers. The 2024 xz backdoor showed why professionals pin versions and read what they install.

Lab 7: C to Python

Rewrite three earlier labs in Python, use lists and dictionaries instead of arrays and hash tables, and time C against Python on the same task. Python · due Fri, Nov 20 · 23:59 · 10 points · opens in week 9 Open lab instructions →

Go deeper

Tags:Pythoninterpreterdynamic typinglistdictexceptionsmodulespip