Skip to content

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.

Module coding progress9 exercises available

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 yet

Use print() to display I am learning Python.

# Write your code below

Lesson 2: Your First Python Program

Not passed yet

Print 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 yet

Write an if True: statement with an indented print() that displays Indented correctly.

# Write your code below

Lesson 4: Variables and Constants

Not passed yet

Create 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 yet

Convert 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 yet

Print exactly Hello, Bangladesh! on one line.

# Print the greeting below

Lab 2: Bus tickets

Not passed yet

One 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 yet

Store 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 yet

a 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.

  • print() (Print objects to the text stream file, separated by sep and followed by end.)
  • input() (Read a line of text typed by a user.)
  • type() (Find out what type of value an object is.)