Skip to content

Commit fc1c46f

Browse files
committed
Further Changes for Topics 8-10
1 parent d1c0a0e commit fc1c46f

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

10) Functions.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
#define
1+
'''
2+
FUNCTIONS: ONE OF THE MOST IMPORTANT PARTS OF PYTHON
3+
A Python function is a group of code that can be called from anywhere after it is defined. Functions can return a value using a return statement.
4+
Function blocks begin with the keyword def followed by the function name and parentheses ( ( ) ). Any input parameters or arguments should be placed within these parentheses. You can also define parameters inside these parentheses.
5+
'''
6+
#Defining a python
27
def say_hi():
38
print("Hello User")
9+
#It won't run until it is called using say_hi()
410

5-
print("top") #comes 1st
6-
say_hi() #calling say hi, comes 2nd
7-
print("bottom") #comes 3rd
11+
print("top") #Comes 1st
12+
say_hi() #Hello User #Calling say_hi, comes 2nd
13+
print("bottom") #Comes 3rd
814

9-
def heya(name, age):
15+
def heya(name, age): # 2 variables used here
1016
print("Hello " + name + "! You are " + age + " years old.")
1117

12-
name = input("Your name: ")
13-
age = input("Your age: ")
14-
heya(name, age)
18+
name = input("Your name: ") #First Variable
19+
age = input("Your age: ") #Second Variable
20+
heya(name, age) #Calling function using the 2 variables

8) Lists.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@
4141
lucky_numbers.reverse() #[42, 23, 16, 15, 8, 4]
4242

4343
numbers2 = lucky_numbers.copy() #Simply copies the list
44-
print(numbers2) #[42, 23, 16, 15, 8, 4]
44+
print(numbers2) #[42, 23, 16, 15, 8, 4]

9) Tuples.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
#Most common is co-ordinates
1+
#Tuples are mostly used for co-ordinates
22
coordinates = (4,5)
3+
34
#tuples are immutable, they cannot be modified.
45
print(coordinates[0]) #4
56
print(coordinates[1]) #5
67

7-
pallete = [(4,5), (6,7), (80,34)]
8+
#Tuples can be used inside lists
9+
pallete = [(4,5), (6,7), (80,34)]

0 commit comments

Comments
 (0)