SkyAICampus
HomePracticeLearnCode LabFocus

Learn

HomePracticeConcept cardsCode LabSky Tutor

Review

Revise todayMistake notebookProgress

Focus

Campus ForestFocus roomsSquads

Questions or feedback?
support@skyaicampus.com

SkyAICampus
PrivacyTermssupport@skyaicampus.com© 2026 SkyAI Campus
← All modules

Python Basics

One 60-second card per skill, in learning order. 9 of 9 cards ready.

Variables and types 3/3Lists and loops 3/3Functions 3/3

In this module

1Variables and types3 of 3 cards2Lists and loops3 of 3 cards3Functions3 of 3 cards

Topic 1

Variables and types

Variables · Data types · Converting types

▶Open the lessonPractise this topic

60-second card

Variables

A variable is a name that points to a value, so you can use and change it later.

  • Create one with = : marks = 82.
  • Names use letters, digits and _, and can't start with a digit.
  • Giving a variable a new value replaces the old one.
marks = 82
marks = marks + 5
print(marks)

Prints

87

Remember: = means 'store this', not 'is equal to'.

Common mistake: Writing 2marks = 82. Names can't start with a digit.

60-second card

Data types

Every value has a type, and the type decides what you can do with it.

  • int: whole numbers like 7. float: decimals like 7.5.
  • str: text in quotes, like "7". bool: True or False.
  • type(x) tells you the type of x.
print(type(7), type(7.5), type("7"), type(True))

Prints

<class 'int'> <class 'float'> <class 'str'> <class 'bool'>

Remember: "7" (text) and 7 (number) are different things.

Common mistake: Expecting 7 / 2 to give 3. In Python 3, / always gives a float: 3.5.

60-second card

Converting types

You can change a value from one type to another with int(), float() and str().

  • int("42") turns text into a whole number.
  • str(42) turns a number into text, so you can join it to other text.
  • int(3.9) cuts off the decimal part: 3. It doesn't round.
age = "20"  # what input() would give you
print(int(age) + 1, str(5) + "5")

Prints

21 55

Remember: input() always gives text. Convert it before doing maths.

Common mistake: Writing "Age: " + 20. Python can't add text and a number; use str(20) or an f-string.

Topic 2

Lists and loops

Lists · For loops · List methods

▶Open the lessonPractise this topic

60-second card

Lists

A list keeps several values in order, in one variable.

  • Write it with square brackets: marks = [72, 85, 90].
  • Positions start at 0: marks[0] is the first item, marks[-1] the last.
  • len(marks) gives how many items there are.
marks = [72, 85, 90]
print(marks[0], marks[-1], len(marks))

Prints

72 90 3

Remember: The first item is at position 0, not 1.

Common mistake: Asking for marks[3] in a 3-item list. The last position is 2, so it's an IndexError.

60-second card

For loops

A for loop runs the same lines once for each item, so you don't repeat yourself.

  • for m in marks: runs once per item, with m set to that item.
  • range(3) gives 0, 1, 2, handy for counting.
  • break stops the loop; continue skips to the next round.
total = 0
for m in [72, 85, 90]:
    total += m
print(total)

Prints

247

Remember: Indent the lines that belong inside the loop.

Common mistake: Expecting range(3) to include 3. It stops just before: 0, 1, 2.

60-second card

List methods

Lists come with built-in methods to add, remove and sort items.

  • append(x) adds to the end; insert(i, x) adds at position i.
  • pop() removes and returns the last item; remove(x) removes the first x.
  • sort() sorts the list in place.
nums = [3, 1, 2]
nums.append(5)
nums.sort()
last = nums.pop()
print(nums, last)

Prints

[1, 2, 3] 5

Remember: sort() changes the list itself and returns None.

Common mistake: Writing nums = nums.sort(). That sets nums to None; just call nums.sort().

Topic 3

Functions

Defining functions · Parameters and return values · Scope

▶Open the lessonPractise this topic

60-second card

Defining functions

A function is a named block of code you can run again whenever you need it.

  • Start it with def, a name, brackets and a colon.
  • The indented lines are the body; they run only when you call the function.
  • Call it with its name and brackets: greet().
def greet():
    print("Namaste!")

greet()
greet()

Prints

Namaste!
Namaste!

Remember: Defining a function doesn't run it. Calling it does.

Common mistake: Calling a function before its def line. Python reads top to bottom, so it isn't defined yet.

60-second card

Parameters and return values

Parameters pass values into a function; return sends a result back out.

  • def add(a, b): has two parameters, a and b.
  • return a + b gives the answer back to whoever called it.
  • A parameter can have a default: def power(n, p=2).
def power(n, p=2):
    return n ** p

print(power(3), power(2, p=3))

Prints

9 8

Remember: print shows a value; return hands it back so you can use it.

Common mistake: Forgetting return. Then the function gives back None.

60-second card

Scope

Variables made inside a function exist only inside it. That's called local scope.

  • A variable created in a function vanishes when the function ends.
  • A function can read a variable from outside it.
  • To change an outside variable, declare it global first (use this rarely).
x = 10

def change():
    x = 99

change()
print(x)

Prints

10

Remember: Prefer returning a value over changing global variables.

Common mistake: Using a function's local variable outside it, which gives a NameError.

Log inSign up

Practise a little every day

Five questions a day keep your Sunrise Streak going. Your progress is saved when you sign up.

Sign up free