forked from portfoliocourses/python-example-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomments.py
More file actions
47 lines (36 loc) · 1.35 KB
/
comments.py
File metadata and controls
47 lines (36 loc) · 1.35 KB
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
################################################################################
#
# Program: Comments
#
# Description: Examples of using comments in Python.
#
# YouTube Lesson: https://www.youtube.com/watch?v=JmqV3r2RH_0
#
# Author: Kevin Browne @ https://portfoliocourses.com
#
################################################################################
# set distance to 200 <-- we use comments like this to document our code
distance = 200
time = 40 # set time to 40 <-- we can call this an inline comment
# Python does not officially have multine comments, but we can use multiple #
# characters (one on each line), or mutliline strings created using either
# ''' or """ style triple quotations as done below.
# Calculate the speed by dividing the distance
# by the time.
"""
Calculate the speed by dividing the distance
by the time.
"""
'''
Calculate the speed by dividing the distance
by the time.
'''
speed = distance / time
# We can experiment with our code by temporarily "commenting out" sections of
# code... for example we could turn this print() below into a comment in order
# to try out a variation (see below). If we didn't like the new code we've
# tried out, we still have the old code avaiable and can just uncomment the
# code by removing the # character.
#
# print("Speed:", speed)
print("Speed ->", speed)