Skip to content
تعلیم کہانی
  • Home
  • Courses
  • Blog Articles
  • Login
  • Toggle website search
Menu Close
  • Home
  • Courses
  • Blog Articles
  • Login
  • Toggle website search

Introduction to Python

  1. Home>
  2. Courses>
  3. Introduction to Python
  • Home
  • Courses
  • Freelancing
  • Introduction to Python

Introduction to Python

Curriculum

  • 2 Sections
  • 26 Lessons
  • 10 Weeks
Expand all sectionsCollapse all sections
  • Week 1
    10
    • 1.1
      Introduction to Python – Part A
      15 Minutes
    • 1.2
      Introduction to Python – Part B
      12 Minutes
    • 1.3
      Setting Up Visual Studio Code for Python Programming and Debugging
      6 Minutes
    • 1.4
      Running Your First Program in Python and Debugging
      9 Minutes
    • 1.5
      Taking Input from the User and Utilizing it
      8 Minutes
    • 1.6
      Cleaning User Input Using ‘Methods’ of Strings
      6 Minutes
    • 1.7
      Good Coding Practices
      14 Minutes
    • 1.8
      Positional and Named Parameters in Python
      9 Minutes
    • 1.9
      Joining String Together
      4 Minutes
    • 1.10
      Assignments for Week 1
      60 Minutes
  • Week 2
    16
    • 2.0
      Manipulating Strings in Python
      14 Minutes
    • 2.1
      Splitting Text and String Expressions in Python
      6 Minutes
    • 2.2
      Data Types for Numbers in Python
      14 Minutes
    • 2.3
      Mathematical Expressions and Operators in Python
      9 Minutes
    • 2.4
      Defining a Custom Function in Python
      14 Minutes
    • 2.5
      How to Get a Return Value from a Function in Python
      12 Minutes
    • 2.6
      Conditional Statements – If, Elif and Else in Python
      10 Minutes
    • 2.7
      Multiple Comparisons using If
      9 Minutes
    • 2.8
      Determine if a Number is Odd or Even in Python
      9 Minutes
    • 2.9
      Match – Case in Python
      8 Minutes
    • 2.10
      Assignments for Week 2
      90 Minutes
    • 2.11
      While Loop In Python
    • 2.12
      For Loops in Python
    • 2.13
      Print Text Multiple Times in Python
    • 2.14
      Infinite Loop Using While, Continue and Break Statements
    • 2.15
      Detailed Look at Lists in Python

Assignments for Week 1

Assignment 1

Create a Python program that can help slow down fast speakers by formatting their input text in a way that introduces pauses. This is inspired by the 0.75x playback speed feature of YouTube. Your program will prompt the user for a string of text and then output the text with each space replaced by three periods (…), creating a visual pause between words.

  • Prompt for Input: Use Python’s input function to ask the user to enter some text. Save this in a variable.
  • Replace Spaces: Use the replace method of strings to replace each space (” “) in the input with three periods (“…”).
  • Show Output: Output the text on the screen.

Your program should work like the following video:

 


 

Assignment 2

Create a Python program that can convert text-based emoticons into their respective Unicode emoji equivalents. Specifically, : ) should be converted to 🙂 (slightly smiling face) and : ( should be converted to 🙁 (slightly frowning face). The program will prompt the user for input, process the input to make the conversions, and then print the result.

  • Create faces.py: Define a convert function to replace : ) with 🙂 and : ( with 🙁.
  • Implement main function: Prompt user input, call convert on it, and print the result.
  • Run the script: Ensure main is called when the script is executed.

Your program should work like the following video:

 


 

Assignment No. 03

Create a program in Python that prompts the user for mass as an integer (in kilograms) and then outputs the equivalent number of Joules as an integer. Assume that the user will input an integer.

Create the file: Name the file `einstein.py`.
Prompt for input: Implement a program that asks the user for mass as an integer in kilograms.
Calculate Joules: Use the formula $(E = mc^2)$ with $(c = 3 \times 10^8) m/s$ to compute energy.
Output the result: Print the energy in Joules as an integer.

Your program should work like the following video:

 


 

Assignment 4

It is customary to leave a tip for your server after dining in a restaurant, typically an amount equal to 15% or more of your meal’s cost. Not to worry, though, we’ve written a tip calculator for you, below!

def main():
    dollars = dollars_to_float(input("How much was the meal? "))
    percent = percent_to_float(input("What percentage would you like to tip? "))
    tip = dollars * percent
    print(f"Leave ${tip:.2f}")

def dollars_to_float(d):
    # TODO

def percent_to_float(p):
    # TODO

main()

 

Well, we’ve written most of a tip calculator for you. Unfortunately, we didn’t have time to implement two functions:

  • dollars_to_float, which should accept a str as input (formatted as \$##.##, wherein each # is a decimal digit), remove the leading \$, and return the amount as a float. For instance, given $50.00 as input, it should return 50.0.
  • percent_to_float, which should accept a str as input (formatted as ##%, wherein each # is a decimal digit), remove the trailing %, and return the percentage as a float. For instance, given 15% as input, it should return 0.15.

Assume that the user will input values in the expected formats.

Hints

  • Recall that input returns a str, per docs.python.org/3/library/functions.html#input.
  • Recall that float can convert a str to a float, per docs.python.org/3/library/functions.html#float.
  • Recall that a str comes with quite a few methods, per docs.python.org/3/library/stdtypes.html#string-methods.

Your program should work like the following video:

 


Joining String Together
Prev
Manipulating Strings in Python
Next
Copyright 2025 - TaleemKahani.com

Modal title

Main Content