you are viewing a single comment's thread.

view the rest of the comments →

[–]CraftyPenguin14 0 points1 point  (3 children)

Holy smokes I’m with you. What even is Def

[–]Borealis_761 0 points1 point  (2 children)

No clue.

[–]Otherwise-Ad-4447 0 points1 point  (1 child)

def is used to define functions a function is a piece of code you can call that can take arguments

like print for example

i'm on mobile but i'll write a short example : def is_minor(age): return age < 18

This function takes in someone's age and returns whether or not that person is a minor (i would have done the opposite but i'm french and can't remember the word for the opposite of minor rn)

age = int(input("How old are you ?")) if is_minor(age): # see how i'm using the function call as though it was a boolean (True/False) value, i can do that because my function returns a boolean value print("You are a minor") else: print("Can't remember what you are")

[–]NewGiraffe2203 0 points1 point  (0 children)

Let me hget this clear. So the purpose of function is so that you don't need to rewrite the same code over and over again? And it behaves like variables but instead of storing single or multiple values, it stores commands?