python function exercises

Solutions on MaxInterview for python function exercises by the best coders in the world

showing results for - "python function exercises"
Sophie
15 Apr 2020
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/
Louisa
15 Nov 2017
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
queries leading to this page
python course with exercisespython practice for beginnerspython program exercisesbasic pythin exercisesbest website for python exercisesfor loop python exercisesfun python exercisesdifficult python exercisespython exercises classesexercises python beginnerspython loop exercisesloop in python exercisesfunctions python exercisespython backend exercisesfunction exercisespythonpython while loop exercises with solutions for beginnerspython easy exercisesexercise on python for beginnersexercise for python beginnerspython exercises with for loopspython exercises with solutionspython exercises for beginners 5cpython programming exercisespython exercises for beginner freesimple python code exercisespython exercisescoding exercises python bookdaily python exercisesfor loop beginner exercises pythonpython def function exercisespython exercises on classeasy exercises pythonpython practice exercises beginnerspython basic functions exercisestutorial python exercisespynative python exercises for beginnersexercises for python beginnerspython list exercisespython loops exercisespython exercises with loopspython function exercises for beginners1000 python exercisesbest python exercises for beginnerslearn python exercisesclasses python exercisespython practice exercisepython exercises for beginners freepython exercises on listexercises on python listpython exercises while looppython exercises looppython practice exercisesexercises for loop pythonpython exercises for beginnerpython drillspython function exercises with solutioneasy python function exercisesonline python coding exercisespython programming exercises for beginnerspython exercises pynativepython exception exercisespython function exercises 5csimple programming exercises pythonpython function exercises with solutionslist of python exercisessimple programming exercises python onlinepython while loop exercises with solutionspreprocessing for machine learning in python exercises with solutionsfree python beginner course exercisesfun for loop python exercisespython problem solving exercisespython ecercise for beginnerpython advanced programming exercisesclass exercises pythonpython exercises for practicepython book with exercisesdaily exercise python programmingcombining instructions exercises in pythonpython code exercisesgood python exercisescool python exercisespython practice problems exercisepython exercises with solutions pdfbasic python exercisespython by problems and exercisessimple python function exercisespython file exercises for beginnersclasic python exercisespython for beginners with exercisespython coding exercises for beginnerseasy python exercisesbasic python exercise100 python program exercisespython class exercises with solutionspython functions exercises 2c practice 2c solutionstatistics exercises to do in pythonlearn python through exercisespython 3 exercisespython functions exercisefunctions in python exercises beginnerssimple python projects exercisespython3 exercises onlinevery simple class python exercisespython function exercisepython exercises online freepython exercises on loopspython set exercisesexercises loops pythonbest exercises for python intermediateeasy python exercises for beginnersfunction more exercises pythonpython exercises solvingpython exercises for advancedexercises for pythonexercises on python engineering programmingloop python exercisesexercises to master pythonpython exercises onlinepython basic coding exercises100 python exerciseseasy python exercises and solutionspython exercises for loopbest sites for python exercisespython modul exercisespython interactive exercisespython module exercisespython exercises with solutions onlinepython list exercises with solutionsgood exercises to learn pythonbest exercises for pythonvery basic python exercisespython programming exercises and solutionslist exercises in pythonadvanced python exercisespython class exercisespython functions basic exercisespython function parameters exercisespython exercises to trypython practice exercises examplesfree python exerciseslist python exercisesexercises beginners pythonpython tutorial and exercises 22practice python by solving 100 interactive python exercises 22python coding interview exercises 3flearn python free exercisespython class programming exercisespython programming exercises websitepython code exercises advancedpython exercises beginnerspython refactoring exercisesadvanced loop exercises in pythonwrite python programs for each of the following programming exercises with numbers 28one python program per each exercise 29function exercises pythonpython coding exercisespython for loop exercises for beginnerspython beginner exercisespython exercises bookpython exercise for beginnerexercise python beginnerssimple exercise for python beginnerspython practice exercises for beginnersexercises for python beginerspython exercises exercismpython examples exercises downloadbasic python functions exercisessolved python exercisesdifficult exercises on python for beginners pdfbeginning python exerciseswebsites for python exercisespython exercises advancedfor loop exercises in pythonpython exercises for functionsbeginers exercises in pythonbegginer python exercisespython training exercisespython exercises on stringspython generator exercisesfor loop in python exercisespython beginners exercisesimple python exerciseswebsites to get python exercisespython basic exercise for beginnerspython from the very beginning with 100 exercises and answers classes in python exercisespython exam exercisesbasic programming exercises in pythonexercises for begginers python online loop python exercisesbasic python coding exercisebest book for python exerciseswhile loop exercises python with ans answersbunch of python exercises questionspython exercise python3 exercisespython distribution exercisesclasses python exercisescoding exercises in pythonsites with intermediate python exercisespython for loop exercisespython exercises for beginners pdfpython challenge exercisespython exercise problemspython coding exercises onlinepython practice problems for beginnersset exercises and solutions in pythonpython loop exercises onlineexercises with if in pythonloops in python exercisespython exercises for beginners practicefor loops python exercisesbasic python list exercisesfunctional programming exercises pythonquick python exercisespython exercises chilipython basics exercisespython programmign online exerciseslearning from data exercises pythonexercises pythonlists python exercisesexercises in pythonpython exercises functionspython function exercisespython exercises for allprogramming exercises pythonbest python programming exercises booknice exercises pythonhow many exercises are in learn python the hard waypython exercises loopspython code exercises onlinepractice python with 100 exercises for beginnersexercises on pythonvery easy python exercisespython scripting exerciseswhile loop python beginners exercisespython functions exercisespython loop exercises with solutionspython intermediate exercisespython practice3 exercisespython exercises on functionspython exercises with answerspython practice problems beginnersimple coding exercises pythononline python exercisesdesign for loop exercises pythontop 5 easy exercises for pythonpythonstring basic to advanced exercises with solutionspython exercises with solutions bookpractice exercises for pythonpython basic exercisespython interractive exercisespython programming exercisepython functions exercises with solutionspython exercises and solutionsbeginer python practicepython challenging programming exercisespython 3 exercises for beginnersprogramming exercises for pythonfunction python exercisespython advanced exercisesexercises on functions pythonexercise pythonengineering exercises with pythonfunctions in python exercisespython arithmetic exercisessets in python exercises200 python exercises 3a an introduction to pythonbeginner list python exercisesfree exercises and solutions on pythonpython exercises questionspython online exercisesbeginner exercises pythoneasy python programming exercisesclasses exercises python100 exercise for python beginnerspython exercises beginnercoding exercises pythonbeginner python exercisesif exercises pythonengineering exercises and solutions with pythonpython program exercisesimple exercises for python beginnerspython practice exercises onlinepython exercisesprogramiz python exercisesbasics python exercisesbest python practice exercises and solutionspython program function exercisepython exercises for beginnerspython function exercises