-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample1.py
More file actions
28 lines (19 loc) · 862 Bytes
/
sample1.py
File metadata and controls
28 lines (19 loc) · 862 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
# At the terminal run the following command to install pylint.
# pip3 install pylint==2.11.1
# Create a new file named sample1.py
# Copy and paste the below code into sample1.py
# Define a function named 'add' that takes two arguments, 'number1' and 'number2'.
def add(number1, number2):
# The function returns the sum of 'number1' and 'number2'.
return number1 + number2
# Initialize the variable 'num1' with the value 4.
num1 = 4
# Initialize the variable 'num2' with the value 5.
num2 = 5
# Call the 'add' function with 'num1' and 'num2' as arguments and store the result in 'total'.
total = add(num1, num2)
# Print the result of adding 'num1' and 'num2' using the 'format' method to insert the values into the string.
print("The sum of {} and {} is {}".format(num1, num2, total))
# Open a terminal
# Run the below command
#pylint sample1.py