w3resource
w3resource.com › python-exercises › python-functions-exercises.php
Python functions - Exercises, Practice, Solution - w3resource
July 12, 2025 - This resource offers a total of 105 Python functions problems for practice. It includes 21 main exercises, each accompanied by solutions, detailed explanations, and four related problems.
Python 3 - functions beginners exercise - Stack Overflow
Python 3, functions. There is the following exercise: Write a function that asks the user to enter his birth year, first name and surname. Keep each of these things in a variable. The function will More on stackoverflow.com
Beginner friendly programming exercises
Thanks for posting! I'm always looking for little exercises I can do at work in my down time.
More on reddit.com46 Simple Python Exercises
Is Code Academy still on Python 2?
More on reddit.comPython Exercises
Try exercises
The repo has solutions as well, for when you get stuck, and new exercises are added to it regularly.
More on reddit.comVideos
PYnative
pynative.com › home › python exercises › python functions exercise
Python Functions Exercise with Solution [10 Programs]
May 22, 2025 - This Python functions exercise aims to help Python developers to learn and practice how to create and use the functions effectively. This exercise contains 10 Python functions questions.
PYnative
pynative.com › home › python exercises
Python Exercises, Practice, Challenges [410+ Exercises] – PYnative
This Python beginner’s exercise helps you quickly learn and practice basic skills by solving coding questions and challenges on below topics. Topics: Python Basics, Variables, Operators, Loops, String, Numbers, List ... This exercise contains coding challenges to solve using if-else conditions, for loops, the range() function, and while loops.
PYnative
pynative.com › home › python exercises › python basic exercise for beginners: 40 coding problems with solutions
Python Basic Exercise for Beginners: 40 Coding Problems with Solutions
February 8, 2026 - The in Keyword: This is a highly optimized Python operator that checks for the existence of an item within a sequence (the string of vowels). Counter Pattern: We use a simple integer (count) that “accumulates” every time the condition evaluates to True. Practice Problem: Given a list of integers, find and print both the largest and the smallest numbers. Exercise Purpose: This exercise explores “Aggregate Functions.” While Python has built-in tools for this, understanding how to identify extremes is critical for data normalization, where you often need to find the range of a dataset before processing it.
GitHub
hplgit.github.io › bumpy › doc › pub › sphinx-basics › ._basics005.html
Exercises
Do Exercise 4: Create a list with a while loop, but use a for loop. Solution. Code: x = [] for n in range(21): x.append(n**2 + 1) print x · One can also make the code shorter using a list comprehension: ... Write a function x(n) for computing an element in the sequence \(x_n=n^2+1\). Call the function for \(n=4\) and write out the result. Solution. Code: ... Write a Python function that evaluates the mathematical functions \(f(x)=\cos(2x)\), \(f'(x)=-2\sin(2x)\), and \(f''(x)=-4\cos(2x)\).
Runestone Academy
runestone.academy › ns › books › published › fopp › Functions › Exercises.html
12.17. Exercises — Foundations of Python Programming
Write a Python function that will take a the list of 100 random integers between 0 and 1000 and return the maximum value. (Note: there is a builtin function named max but pretend you cannot use it.) ... Write a function sum_of_squares(xs) that computes the sum of the squares of the numbers ...
Top answer 1 of 3
3
Make sure to call your function, so that it gets executed:
def user_input():
birth_year = int(input("enter your birth year:\n"))
first_name = input("enter your first name:\n")
surname = input("enter your surname:\n")
print("your initials are {1}{2} and you are {0} years old".format(first_name[0], surname[0], 2021-birth_year))
# Call it here
user_input()
2 of 3
1
The terminal stays empty is because you did not call the function to execute it.
def user_input():
birth_year = int(input("Please enter your birth year: "))
surname = input("Please enter your surname: ")
first_name = input("Please enter your first name: ")
print("\n\nYour initials are {1}{0} and you are {2} years old".format(first_name[0], surname[0], 2021-birth_year))
# remember to call the function
user_input()
Gitbooks
erlerobotics.gitbooks.io › erle-robotics-learning-python-gitbook-free › content › functions › exercises_functions.html
Exercises: Functions | Erle Robotics Learning Python GitBook Free
First, def a function, shut_down, that takes one argument s. Then, if the shut_down function receives an s equal to "yes", it should return "Shutting down" Alternatively, elif s is equal to "no", then the function should return "Shutdown aborted".
Codesolid
codesolid.com › python-function-exercises
Python Function Exercises With Solutions — CodeSolid.com 0.1 documentation
def fizzbuzz(value: int) -> str: result = "" if value % 3 == 0: result += "fizz" if value % 5 == 0: result += "buzz" return result values = [3,6,9,11,10,20,40,23,15,30,60] for value in values: print(fizzbuzz(value)) ... 8. There are six New England states: Rhode Island, Connecticut, Massachusetts, Maine, Vermont, and New Hampshire. Their postal abbreviations are RI, CT, MA, ME, VT, and NH, respectively. Write a function that takes a New England state code as a string and returns a string with the longer name as shown above. Return None if no mapping is found. ... Whenever an exercise calls for mapping one value to another, think “dictionary”! Once you realize that, the function boils down to creating the dictionary and passing the key (in this case, the state code), to the get function.
360 Learning
learning.360-bytes.com › home › blog › 10 python function exercises for beginners to master the basics
10 Python Function Exercises for Beginners to Master the Basics - 360 Learning
September 4, 2024 - Modify the previous Python function to allow for an arbitrary shift, effectively creating a Caesar cipher. The function should take a string and an integer (representing the shift) as input and return a new string where every character is shifted by the specified amount in the alphabet. ... If you pay close attention, this one is quite straightforward! Compared to the previous exercise, the only difference in the caesar_cipher() function is that it now takes an integer jump along with the input_string.
HolyPython
holypython.com › home › beginner python exercises
Beginner Python Exercises w/ Solutions | HolyPython.com
November 8, 2022 - Exercise 10: len() function | (5) : Python’s len function tells the length of an object. It’s definitely a must know and very useful in endless scenarios. Whether it’s manipulating strings or counting elements in a list, len function is constantly used in computer programming. Exercise 11: .sort() method | (7) : Practice sort method in Beginner Python Exercises and later on you’ll have the opportunity practice sorted function in Intermediate Python Exercises.
Python Lobby
pythonlobby.com › home › python function exercises with solution
Python Function Exercises with Solution
June 17, 2021 - The main idea behind solving these questions is to make your concept more clear and improve logical thinking of how to approach a problem in a functional way. We are going to cover python functions with some mix of conditional statements i.e if, if-else, for loop(), range(), while loop() etc. ... We will solve 15 function exercises in python with a solution & detailed code explanation.
360 Learning
learning.360-bytes.com › home › blog › the python functions guide: a guide to python functions – practice exercises for beginners
Python Functions Exercises for Beginners
September 9, 2025 - In order to remain up to date and be able to practice Python functions, it is possible to consider the following resources: This site provides more than 100 exercises that are either at a basic or advanced level. There are solutions and explanations attached to every exercise, which makes them perfect in self-paced learning. Recursion, lambda functions and concepts of functional programming are topics of discussion. Catered to beginners, this source offers 10 actual exercises devoted to basic functioning concepts.
DataCamp
datacamp.com › tutorial › python-exercises-for-beginners
Python Exercises for Beginners: A Hands-On Guide With Answers | DataCamp
3 weeks ago - Understanding *args makes it easier to read and use real‑world Python libraries, where functions often accept a flexible number of parameters for convenience and extensibility. ... def print_args(*args) -> None: """Print each positional argument on its own line.""" # Task: Loop over args and print each one # for ...: # print(...) pass # Optional quick test # print_args("hello", 42, True) ... Exercises build skills, but projects turn those skills into confidence.
GitHub
github.com › Pierian-Data › Complete-Python-3-Bootcamp › blob › master › 03-Methods and Functions › 03-Function Practice Exercises.ipynb
Complete-Python-3-Bootcamp/03-Methods and Functions/03-Function Practice Exercises.ipynb at master · Pierian-Data/Complete-Python-3-Bootcamp
Course Files for Complete Python 3 Bootcamp Course on Udemy - Complete-Python-3-Bootcamp/03-Methods and Functions/03-Function Practice Exercises.ipynb at master · Pierian-Data/Complete-Python-3-Bootcamp
Author Pierian-Data