#đź”’ Why does some functions have : or () next to them?

15 messages · Page 1 of 1 (latest)

hollow coral
#

For example:
Def my_fuction():
print(“hello world”)

timid dustBOT
#

@hollow coral

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

tardy thorn
#

for example

#
# 'a' and 'b' cannot be accessed here since it is outside the function
def func1():
  a = 10 # These are defined inside the function, so they cannot be accessed outside the function
  b = 20 # same here
  c = func2(a, b) # but what we can do is pass those variables from inside this function to another function

def func2(a, b):
  return a + b
magic pendant
dusty wagon
spark swallow
#
def add(a,b):#defining the function,":" is a syntax,means u need to use it
       c=a+b
       return c
x=add(3,5)#when I do this it's called calling a function,then 3 and 5 goes and sits in 'a' and 'b' returns the sum which is c
dusty wagon
spark swallow
#

My bad typo

magic pendant
dusty wagon
#

sure, but it was unnecessary to have it at the end of the line like they had before the edit

spark swallow
#

Yea my bad I m on phone

timid dustBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.