-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.py
More file actions
54 lines (40 loc) · 994 Bytes
/
Copy pathfunctions.py
File metadata and controls
54 lines (40 loc) · 994 Bytes
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
# #include <iostream>
# using namespace std;
# // Function declaration (prototype)
# int add(int a, int b);
# // Function definition
# int add(int a, int b) {
# return a + b;
# }
# int main() {
# int result = add(5, 3);
# cout << result << endl;
# return 0;
# }
# Function definition (no prototype needed!)
def add(a, b):
return a + b
# Function call
result = add(5, 3)
print(result)
# No return type needed!
def greet(name):
print(f"Hello, {name}!")
# Call the function
greet("Alice") # Hello, Alice!
# Function with return value
def add(a, b):
return a + b
result = add(10, 5)
print(result) # 15
# Function with multiple returns
def get_stats(numbers):
return min(numbers), max(numbers), sum(numbers) / len(numbers)
minimum, maximum, average = get_stats([1, 2, 3, 4, 5])
print(f"Min: {minimum}, Max: {maximum}, Avg: {average:.2f}")
a=10
b=9
if(a>b):
pass
# this pass will say python to do nothing and
# continue with the rest of the code.