-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay16.py
More file actions
73 lines (44 loc) · 1.79 KB
/
Copy pathDay16.py
File metadata and controls
73 lines (44 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# function = a block of code which is executed only when it is called.
def hello(): # def is the keyword for function & create a function
print("Hello! ") # print hello!
print("Have a nice day!")
# call the function
hello()
def helloo(name): # call the function by name and matching argument
print("hello! " + name) # print hello! + argument [name]
print("Have a nice day!")
# call the function with argument
helloo("Prawin") # argument 1
helloo("Dude") # argument 2
def hello(name):
print("Hello " + name)
print("Have a nice Day!")
my_name = "Bro"
hello(my_name)
# call the function by pass the two arguments
def helo(first_name, last_name):
print("Hello! " + first_name + " " + last_name)
print("Have a nice day! ")
helo("Prawin", "Kumar") # function(arg1, arg 2)
print("NEXT")
# always keep mind!!!
# when you call the function always give two line empty space (Only for pycharm)
# return statement = Function send python values/object back to the caller.
# These values/objects are known as the function's return values.
def multiply(number_1, number_2): # function with argument 1, 2
result = number_1 * number_2 # multiple and store the value
return result # return the value
x = multiply(1, 4) # assign a variable and call the function with arg 1, 2
print(x) # print the value
# simplified code
def multiply(number1, number2):
return number1 * number2
x = multiply(6, 9)
print(x)
# own content
def add(a, b):
return a + b
num_1 = int(input("Enter the number 1 : "))
num_2 = int(input("Enter the number 2 : "))
result = add(num_2, num_1)
print("The Answer is : " + str(result))