Skip to content

Commit 1bf4c6f

Browse files
authored
Merge pull request mouredev#6987 from Jackziel-Sumoza/main
#2 - Python
2 parents 6f2aa0e + 1ae4781 commit 1bf4c6f

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# function without argument
2+
def function():
3+
pass
4+
function()
5+
6+
# function with unique argument and without return
7+
def function_1(name):
8+
print(f"Hello {name}")
9+
function_1("World")
10+
11+
12+
# function with two argument and one return
13+
def function_2(name,lastname):
14+
return f"Hello {name} and hello {lastname}"
15+
result = function_2("world","Python")
16+
print(result)
17+
18+
# function multi-argument
19+
def function_3(*num):
20+
print(sum(num))
21+
function_3(1,2,3,4,5,6,7,8,9)
22+
23+
# function with one default argument
24+
def function_4(name="Python"):
25+
print(f"Hello {name}")
26+
function_4()
27+
28+
# function key-value
29+
def function_5(**values):
30+
for key, value in values.items():
31+
print(f"The {key} is {value}")
32+
function_5(name="Jackziel",lastname="Sumoza",age="?")
33+
34+
# function in function
35+
def hello(name):
36+
print(f"hello {name}")
37+
def bye(name):
38+
print(f"see you soon {name}")
39+
bye(name)
40+
hello("World")
41+
42+
# native function
43+
print(type(4.4))
44+
45+
# local variable
46+
def function_6():
47+
local_var = "Python"
48+
print(f"Hello, {local_var}")
49+
# print(local_var); error
50+
function_6()
51+
52+
# global variable
53+
global_variable = "This is a global variable"
54+
print(global_variable)
55+
56+
# additional difficult
57+
print()
58+
def occurrence(text_1,text_2):
59+
occurrence_num = 0
60+
for num in range(1,101):
61+
if num % 3 == 0:
62+
print(text_1)
63+
elif num % 5 == 0:
64+
print(text_2)
65+
elif num % 3 == 0 and num % 5 == 0:
66+
print(text_1 + text_2)
67+
else:
68+
occurrence_num += 1
69+
print(num)
70+
return occurrence_num
71+
72+
result = occurrence("Hello","Bye")
73+
print()
74+
print(result)

0 commit comments

Comments
 (0)