Practice module 1
>Python Basics: coding practice
Start with the lesson drills, then combine the ideas in the module labs. Every task has automatic checks, progressive hints, reset and a solution.
Lesson coding drills
One focused editor exercise for every lesson in this module. (0/5 passed this visit)
You can run every exercise now. Create a free ID to keep passes, code attempts and XP.
Lesson 1: Introduction to Python
Not passed yetUse print() to display I am learning Python.
# Write your code below
Lesson 2: Your First Python Program
Not passed yetPrint the values red, green, and blue on one line, separated by | (a space, vertical bar, and space).
# Write your code below
Lesson 3: Python Syntax and Comments
Not passed yetWrite an if True: statement with an indented print() that displays Indented correctly.
# Write your code below
Lesson 4: Variables and Constants
Not passed yetCreate variables first and second with values "sun" and "moon". Swap them, then print first followed by second.
# Write your code below
Lesson 5: Data Types and Type Conversion
Not passed yetConvert the text "12" to an integer, add 3, and print the result.
# Write your code below
Coding practice: write it yourself
Real Python, real checks: write your answer, press Run checks, and keep going until it passes. (0/4 passed this visit)
You can run every exercise now. Create a free ID to keep passes, code attempts and XP.
Lab 1: Say hello
Not passed yetPrint exactly Hello, Bangladesh! on one line.
# Print the greeting below
Lab 2: Bus tickets
Not passed yetOne Dhaka-to-Gazipur ticket costs 450 taka. Store the price and the number of tickets (3) in variables, then print the total.
price = 450 tickets = 3 # print the total cost
Lab 3: Student ID line
Not passed yetStore the name Mim and age 17 in variables, then print them on ONE line separated by a space: Mim 17.
name = "Mim" age = 17 # print both, space-separated
Lab 4: Swap two cups
Not passed yeta holds "tea" and b holds "coffee". Swap their values so printing gives coffee tea.
a = "tea" b = "coffee" # swap, then print(a, b)
References & Further Reading
Related entries from PyLabs's own reference library.