11,000+ Python Practice Challenges // Edabit
2go to : https://edabit.com/challenges/python3
1Exercise 1: Create a function that can accept two arguments name and
2 age and print its value
3Exercise 2: Write a function func1() such that it can accept a variable
4 length of argument and print all arguments value
5Exercise 3: Write a function calculation() such that it can accept two
6 variables and calculate the addition and subtraction of them. And a
7 lso it must return both addition and subtraction in a single return
8 call
9Exercise 4: Create a function showEmployee() in such a way that it
10 should accept employee name, and its salary and display both.
11 If the salary is missing in the function call assign default value
12 9000 to salary
13Exercise 5: Create an inner function to calculate the addition in the
14 following way
15Exercise 6: Write a recursive function to calculate the sum of numbers
16 from 0 to 10
17Exercise 7: Assign a different name to function and call it through the
18 new name
19Exercise 8: Generate a Python list of all the even numbers between 4 to
20 30
21Exercise 9: Return the largest item from the given list
22
23⤵️⤵️⤵️⤵️⤵️⤵️⤵️⤵️⤵️ GOTO URL FOR PRACTICE ⤵️⤵️⤵️⤵️⤵️⤵️⤵️⤵️⤵️⤵️
24https://pynative.com/python-functions-exercise-with-solutions/
1# Let me know if there's any mistakes or errors as this is original :)
2
3# This look a ton of effort to make and this is mainly for beginners to practice.
4# Good luck and have fun!
5
6'Predict the following output for the questions below.'
7
8# Question 1:
9num1 = 5
10num2 = 6
11print(sum(num1, num2))
12
13# Question 2:
14def f2(x, y):
15 return ((y * 2) // y) - ((y - x) * y)
16print(f1(1, 2))
17
18# Question 3:
19from math import floor
20
21try:
22 print(math.floor(3.31))
23except:
24 print(floor(33.1))
25
26# Question 4:
27my_list = [1, 2, 3, 4, 5]
28print([my_list**2 for i in my_list if i % 2 == 0])
29
30# Question 5:
31for i in range(10):
32 if i == 10:
33 print('hit')
34 break
35else:
36 print('no hit')
37
38# Question 6:
39stuff = [i for i in range(6)]
40if not any(stuff):
41 print('no stuff inside.')
42else:
43 print('there is stuff inside.')
44
45# Question 7:
46def f7(*num):
47 return [i for x, i in enumerate(num) if x == 1]
48print(f7(1, 2, 3, 4, 5)[0])
49
50# Question 8:
51print(True ** (True + True) - True + True == True)
52
53# Question 9:
54print( (lambda *x: sum(x))(2, 4, 6, 8) )
55
56# <ANSWERS>
57(1) 11
58(2) 0
59(3) 33
60(4) my_list = [1, 4, 3, 16, 5]
61(5) 'no hit'
62(6) 'there is stuff inside'
63(7) 2
64(8) True OR 1
65(9) 20