Lesson guide
What this Python exercise practices
Calculate Square of a Number is a beginner practice lesson that focuses on functions, parameters, return values. It is designed to be solved in about 8 minutes with examples, starter code, and test feedback.
Prerequisites
- Python variables
- Function parameters
- Return values
Difficulty and time
- Level
- Beginner
- Estimated time
- 8 minutes
Practice path
Summary
Learn how to compute the square of a given number using a simple function.
Problem statement
You need to create a function named `calculate_square` that takes a single argument (a number) and returns the square of that number. The square of a number is obtained by multiplying the number by itself.
Task
Write a function that takes a number and returns its square.
Examples
Example 1
Input
calculate_square(4)
Output
16
Explanation
The square of 4 is 4 * 4 which equals 16.
Input format
A single integer or float.
Output format
An integer or float representing the square of the input.
Constraints
The input number can be any valid integer or float.
Samples
Sample input 0
5
Sample output 0
25
Explanation 0
The square of 5 is 5 * 5 which equals 25.
AI assistant
Ask me anything!
Need help? I can explain the core idea behind this problem, review your current code, and give targeted hints. Use “Teach Theory” for the concept, “Get AI hint” for a quick scaffold nudge, or ask a specific question below.
Chat history is temporary and will not be saved.
Free preview includes 1 Teach Theory response and 1 AI hint on each of the first 3 lessons in this module.