Hi there.. who can tell me about functions & models in the part 3 I don't understand | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Hi there.. who can tell me about functions & models in the part 3 I don't understand

I mean I don't understand what to do in functions & models in the question lvl 3 I don't understand it

1st Feb 2019, 1:00 PM
karlloss
4 Answers
+ 5
Functions are used so that you can reuse them. For example, if you needed to keep checking how much stock was in your shop, it would be easier to write a function then keep on writing the code. In python, functions are written like: def func(): your_code Inside the brackets, you can add what we call arguments, which the function uses to help it run. For example in the shop again, you might need to 'tell' the function how much stock you have bought, how much you need, ect. This is how you give arguments: def stock(bought, sold): your_code stock(10, 5) #this runs it Hope this helps!
2nd Feb 2019, 8:39 AM
Eragon1980
Eragon1980 - avatar
+ 2
Which language?
2nd Feb 2019, 8:17 AM
Eragon1980
Eragon1980 - avatar
2nd Feb 2019, 8:31 AM
karlloss
+ 1
In sayhallo have parameter. The parameter is david. When it call sayhallo. So the function is output hi. Dahid(name)
4th Feb 2019, 6:56 PM
Mr. X
Mr. X - avatar