Skip to contentSkip to navigation

Module 1 of 6, Python Foundations

Getting Started

Write and run your first programs, and store values in named variables of the right type.

module checksSign in to track

  • Lessons complete-, not done
  • Lesson quizzes taken-, not done
  • Module Labs passed-, not done
  • Module exam passed at 80%-, not done
lessons
4
quiz questions
48
reading time
32 min
exam length
15 Q
coding exercises
8

Lessons

  1. Introduction to PythonMeet Python: what a program is, how the interpreter runs your lines from top to bottom, and how to read an error message without panic. 8 min 12 questions
  2. Your First Python ProgramWrite your first real programs: shape print() output with sep, end and escape sequences, and follow Python's rules for lines, indentation and comments. 8 min 12 questions
  3. Variables & Dynamic TypingStore values under names, change them as the program runs, update them with +=, swap two at once, and mark values that should never change as constants. 8 min 12 questions
  4. Core Data Types & Type ConversionLearn Python's everyday types, int, float, str and bool, check a value's type with type(), and convert between them with int(), float(), str() and bool(). 8 min 12 questions

Lab: write it yourself

Real Python, real checks: write your answer, press Run checks, and keep going until it passes. (4 exercises)

All module exercises

The Lab needs an account. Sign in or create a free ID to run these exercises.

Lab 1: Say hello

Sign-in required

Print exactly Hello, Bangladesh! on one line.

Sign in to practise

Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.

Lab 2: Bus tickets

Sign-in required

One Dhaka-to-Gazipur ticket costs 450 taka. Store the price and the number of tickets (3) in variables, then print the total.

Sign in to practise

Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.

Lab 3: Student ID line

Sign-in required

Store the name Mim and age 17 in variables, then print them on ONE line separated by a space: Mim 17.

Sign in to practise

Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.

Lab 4: Swap two cups

Sign-in required

a holds "tea" and b holds "coffee". Swap their values so printing gives coffee tea.

Sign in to practise

Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.

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