Coding Challenges
Practice coding with bite-sized challenges.
How Edabit Works
This is an introduction to how challenges on Edabit work. In the code editor below you'll see a starter function that looks like this: def hello(): All you have to do is type return "hello edabit.com" on the second line and then click the Check button. If you did this correctly, a celebration window will pop up. Notes The returned string must be in all loweReturn the Sum of Two Numbers
Create a function that takes two numbers as arguments and returns their sum. Examples addition(3, 2) ➞ 5 addition(-3, -6) ➞ -9 addition(7, 3) ➞ 10 Notes Don't forget to return the result. If you get stuck on a challenge, find help in the Resources tab. If you're really stuck, unlock solutions in the Solutions tab.Return the Next Number from the Integer Passed
Create a function that takes a number as an argument, increments the number by +1 and returns the result. Examples addition(0) ➞ 1 addition(9) ➞ 10 addition(-3) ➞ -2 Notes Don't forget to return the result. If you get stuck on a challenge, find help in the Resources tab. If you're really stuck, unlock solutions in the Solutions tab.Convert Minutes into Seconds
Write a function that takes an integer minutes and converts it to seconds. Examples convert(5) ➞ 300 convert(3) ➞ 180 convert(2) ➞ 120 Notes Don't forget to return the result. If you get stuck on a challenge, find help in the Resources tab. If you're really stuck, unlock solutions in the Solutions tab.Player Two Has Joined
Someone has joined your game! Create join_message to return their username followed by " has joined!". For "Nova", return "Nova has joined!". Examples join_message("Nova") # "Nova has joined!" joinmessage("Pixel7") # "Pixel_7 has joined!" join_message("x") # "x has joined!" Notes username contains 1 to 20 English letters, digits or underscores. Keep it uMake It a Hashtag
Turn one word into a hashtag. Create make_hashtag to put "#" before word and return the new string. Keep the word just as it is. Examples make_hashtag("coding") # "#coding" make_hashtag("PixelArt") # "#PixelArt" make_hashtag("X") # "#X" Notes word contains 1 to 20 English letters, with no spaces or existing #. Do not change its capital letters.One More Encore
The crowd wants one more song! Create encore_total to return the total number of songs after the band adds one encore to songs. Examples encore_total(8) # 9 encore_total(0) # 1 encore_total(20) # 21 Notes songs is a whole number from 0 to 100. The encore always adds exactly one song.Name That Playlist
Give your playlist a name to match its mood. Create playlist_name to return mood followed by " Mix". For "Late Night", return "Late Night Mix". Examples playlist_name("Late Night") # "Late Night Mix" playlist_name("Focus") # "Focus Mix" playlist_name("Rainy Day") # "Rainy Day Mix" Notes mood is a nonempty string of at most 30 characters, with no spaces aArea of a Triangle
Write a function that takes the base and height of a triangle and return its area. Examples tri_area(3, 2) ➞ 3 tri_area(7, 4) ➞ 14 tri_area(10, 10) ➞ 50 Notes The area of a triangle is: (base * height) / 2 Don't forget to return the result. If you get stuck on a challenge, find help in the Resources tab. If you're really stuck, unlock solutions in the SoluBuggy Code (Part 1)
Fix the code in the code tab to pass this challenge (only syntax errors). Look at the examples below to get an idea of what the function should do. Examples cube(3) ➞ 27 cube(5) ➞ 125 cube(10) ➞ 1000 Notes READ EVERY WORD CAREFULLY, CHARACTER BY CHARACTER! Don't overthink this challenge; it's not supposed to be hard.Convert Hours into Seconds
Write a function that converts hours into seconds. Examples howmanyseconds(2) ➞ 7200 howmanyseconds(10) ➞ 36000 howmanyseconds(24) ➞ 86400 Notes 60 seconds in a minute, 60 minutes in an hour Don't forget to return your answer.Maximum Edge of a Triangle
Create a function that finds the maximum range of a triangle's third edge, where the side lengths are all integers. Examples next_edge(8, 10) ➞ 17 next_edge(5, 7) ➞ 11 next_edge(9, 2) ➞ 10 Notes (side1 + side2) - 1 = maximum range of third edge. The side lengths of the triangle are positive integers. Don't forget to return the result.Return the Remainder from Two Numbers
There is a single operator in Python, capable of providing the remainder of a division operation. Two numbers are passed as parameters. The first parameter divided by the second parameter will have a remainder, possibly zero. Return that value. Examples remainder(1, 3) ➞ 1 remainder(3, 4) ➞ 3 remainder(5, 5) ➞ 0 remainder(7, 2) ➞ 1 Notes The tests only usReturn a String as an Integer
Create a function that takes a string and returns it as an integer. Examples string_int("6") ➞ 6 string_int("1000") ➞ 1000 string_int("12") ➞ 12 Notes All numbers will be whole. All numbers will be positive.Convert Age to Days
Create a function that takes the age in years and returns the age in days. Examples calc_age(65) ➞ 23725 calc_age(0) ➞ 0 calc_age(20) ➞ 7300 Notes Use 365 days as the length of a year for this challenge. Ignore leap years and days between last birthday and now. Expect only non-negative integer inputs.Find the Perimeter of a Rectangle
Create a function that takes length and width and finds the perimeter of a rectangle. Examples find_perimeter(6, 7) ➞ 26 find_perimeter(20, 10) ➞ 60 find_perimeter(2, 9) ➞ 22 Notes Don't forget to return the result. If you're stuck, find help in the Resources tab. If you're really stuck, find solutions in the Solutions tab.Power Calculator
Create a function that takes voltage and current and returns the calculated power. Examples circuit_power(230, 10) ➞ 2300 circuit_power(110, 3) ➞ 330 circuit_power(480, 20) ➞ 9600 Notes power is voltage multiplied by current.Open the Loot Chest
A loot chest needs a certain number of keys. Create canopenchest to return True if keys is at least needed, and False if you do not have enough. Examples canopenchest(3, 2) # True canopenchest(2, 2) # True canopenchest(1, 2) # False Notes keys is a whole number from 0 to 100. needed is a whole number from 1 to 100. Return a boolean, not a message.Spaceship Fuel Check
Mission control has already worked out the fuel needed for your trip. Create hastripfuel to return True when available fuel is at least needed, or False when it is not enough. Examples hastripfuel(30, 40) # False hastripfuel(40, 40) # True hastripfuel(50, 40) # True Notes available and needed are whole numbers from 0 to 1000. The exact amount is enough.Coffee Supply
Plan your coffee supply. Create coffeesupply to return the total number of cups you will need if you drink cupsper_day cups each day for days days. Examples coffee_supply(2, 5) # 10 coffee_supply(1, 7) # 7 coffee_supply(0, 10) # 0 Notes cupsperday is a whole number from 0 to 10. days is a whole number from 0 to 30. Return the total number of cups.