Variables, Keywords, Expressions, Statements
Variables, Keywords, Expressions, Statements
Statements
Program
Comments
• It is a good idea to add notes to your programs to explain in natural
language what the program is doing. These notes are called comments.
• they are marked with the # symbol:
•For eg:
# compute the percentage of the hour that has elapsed
percentage = (minute * 100) / 60
Questions ??
Programs
1 There are 5280 feet in a mile. Write a Python statement that
calculates and prints the number of feet in 13 miles
2 Write a Python statement that calculates and prints the number of
seconds in 7 hours, 21 minutes and 37 seconds.
3 The perimeter of a rectangle is 2w+2h, where w and h are the lengths
of its sides. Write a Python statement that calculates and prints the
length in inches of the perimeter of a rectangle with sides of length 4
and 7 inches.
Programs
Write a single Python statement that combines the three strings "My
name is", "Joe" and "Warren" (plus a couple of other small strings) into
one larger string "My name is Joe Warren." and prints the result.