Help
Contact
For teachers and institutes
Search courses, problems, tests…
A
A
>_
StemPy Lab
Courses ▾
Problems ▾
Practice ▾
Mock Tests
Classes
Groups
Community ▾
A
A
Problems
/
Python Basics
/
Functions
Functions
Python Programming
+ Upload a Problem
More in Python Basics
Getting Started with Python
Variables and Data Types
Operators and Expressions
Input and Output
Strings
Conditionals: if, elif, else
Loops
Lists
Functions
Mini Projects
All Levels
Middle Stage (6–8)
High School (9–10)
High School (11–12)
Undergraduate
General
All
Easy
Medium
Hard
Sort
Mixed
Newest first
Oldest first
A to Z
14 problems
Type:
Any
Conceptual
Numerical
Python-Coded
1.
A function ticket_price(age) gives the price of a museum ticket: under 5 is free (0), under 13 pays…
Middle Stage (6–8), High School (9–10), High School (11–12), Undergraduate, General · Functions
StemPy Lab
Medium
2.
Same name, two variables
Middle Stage (6–8), High School (9–10), High School (11–12), Undergraduate, General · Functions
StemPy Lab
Medium
3.
This program should show The total is 50. It stops with an error. Find the fault and fix it.
Middle Stage (6–8), High School (9–10), High School (11–12), Undergraduate, General · Functions
StemPy Lab
Medium
4.
Which of these four programs shows something? Say it before you run each one.
Middle Stage (6–8), High School (9–10), High School (11–12), Undergraduate, General · Functions
StemPy Lab
Easy
5.
Why does this program stop with a NameError? Fix it.
Middle Stage (6–8), High School (9–10), High School (11–12), Undergraduate, General · Functions
StemPy Lab
Hard
6.
Write a function total(items) that adds a list, and a function average(items) that uses total.
Middle Stage (6–8), High School (9–10), High School (11–12), Undergraduate, General · Functions
StemPy Lab
Hard
7.
Write a function power(base, exponent=2). What are power(5), power(2, 10) and power(10, 3)?
Middle Stage (6–8), High School (9–10), High School (11–12), Undergraduate, General · Functions
StemPy Lab
Medium
8.
Write a function c_to_f(celsius) with F = C × 9/5 + 32. What does it return for 37, 100 and -40?
Middle Stage (6–8), High School (9–10), High School (11–12), Undergraduate, General · Functions
StemPy Lab
Medium
9.
Write a function bigger(a, b) that returns the bigger of two numbers, without using max.
Middle Stage (6–8), High School (9–10), High School (11–12), Undergraduate, General · Functions
StemPy Lab
Medium
10.
Write a function is_even(n) that returns True if n is even, and False if it is odd.
Middle Stage (6–8), High School (9–10), High School (11–12), Undergraduate, General · Functions
StemPy Lab
Medium
11.
One function shows its answer with print.
Middle Stage (6–8), High School (9–10), High School (11–12), Undergraduate, General · Functions
StemPy Lab
Hard
12.
Write a function area(length, width) that returns the area. What are area(5, 3) and area(12.5, 4)?
Middle Stage (6–8), High School (9–10), High School (11–12), Undergraduate, General · Functions
StemPy Lab
Easy
13.
Write a function greet(name) that shows Hello, followed by the name and an exclamation mark.
Middle Stage (6–8), High School (9–10), High School (11–12), Undergraduate, General · Functions
StemPy Lab
Easy
14.
Write a function say_hello that shows Hello!. Call it three times.
Middle Stage (6–8), High School (9–10), High School (11–12), Undergraduate, General · Functions
StemPy Lab
Easy