Solutions to CS50’s Week 0: Python assignments — Indoor Voice, Playback Speed, Making Faces, Einstein, and Tip Calculator.
This repository contains my solutions to CS50’s Week 0 (Python) problem sets.
The projects here introduce the fundamentals of programming in Python, including:
- Taking user input/output
- Performing string manipulation
- Using functions and variables
- Applying arithmetic operations
- Writing interactive programs
These problems are the first step of the CS50 journey, helping me build a strong foundation before moving to C, SQL, and web development.
Converts all uppercase input into lowercase, simulating an “indoor voice.”
- Concepts: Strings,
.lower()
function, user input - Run:
python indoor.py
##Example Run:
Input: HELLO, WORLD Output: hello, world 2. Playback Speed
Replaces spaces in user input with ... to mimic slower speech.
Concepts: String replacement with .replace()
Run:
python indoor.py
Example Run:
Input: This is CS50 Output: This...is...CS50
3. Making Faces
Replaces typed emoticons with emoji symbols.
:) → 😀
:( → 🙁
Concepts: Functions, string replacement, conditionals
Run:
python faces.py
Example Run:
Input: I am happy :) Output: I am happy 😀
Input: I am sad :( Output: I am sad 🙁
4. Einstein
Implements Einstein’s formula E = mc². The program prompts for mass (m, in kilograms) and outputs the equivalent energy (E, in joules).
Concepts: Arithmetic operations, integers, variables
Run:
python einstein.py
Example Run:
Input: 1 Output: 9000000000
Input: 50 Output: 450000000000
5. Tip Calculator
Calculates the tip based on the meal cost and desired tip percentage.
Concepts: Floats, arithmetic, string formatting, functions
Run:
python tip.py
Example Run:
Input: Cost of meal: $100 Input: Tip percentage: 15% Output: $15.00
Input: Cost of meal: $65.50 Input: Tip percentage: 20% Output: $13.10