Professional Documents
Culture Documents
Lab 01 A
Lab 01 A
Full-Name:
ID card:
Tel.:
Email:
2. Install the Python extension for VS Code from the Visual Studio Marketplace. For additional
details on installing extensions, see Extension Marketplace. The Python extension is
named Python, and Microsoft publishes it. (https://marketplace.visualstudio.com/items?
itemName=ms-python.python).
Reference: https://code.visualstudio.com/docs/python/python-tutorial
The second way, you can create a .py file in your local disk and then mount your file to the Google
Colab following the guideline below:
1. Enter the Google Colab: https://colab.research.google.com/notebooks/welcome.ipynb?hl=in
2. Mounting drive
- Click “Tool” -> “Command Pallette” or “Ctrl + Shift + P”
- Type “m” and select “Mount Drive”
>>>
Code Insert\Scrennshot
# first condition
result = multiplication_or_sum(30,
40)
print("The result is", result)
# Second condition
result = multiplication_or_sum(40,
50)
print("The result is", result)
2. Print the sum of the current number and the previous number
Write a program to iterate the first 10 numbers and in each iteration, print the sum of the current
and previous number.
>>>
Code Insert\Scrennshot
# AI1701 - PFP191 - 24-4-2022
print("Printing current and previous number
and their sum in a range(10)")
previous_num = 0
# loop from 1 to 10
for i in range(1, 11):
x_sum = previous_num + i
print("Current Number", i, "Previous
Number ", previous_num, " Sum: ",
previous_num + i)
# modify previous number
# set it to the current number
previous_num = i
>>>
Code Insert\Scrennshot
# AI1701 - PFP191 - 24-4-2022
print('My', 'Name', 'Is', 'AI1701 - PFP191',
sep='**')
>>>
Code Insert\Scrennshot
# AI1701 - PFP191 - 24-4-2022
num = 81
print("The octal number of decimal number
is:",'%o' % num)
2. Display float number with 2 decimal places using print()
>>>
Code Insert\Scrennshot
num = 458.541315
print("Display float number with 2 number:",
'%.2f' % num)