Appendix
About
This section is included to assist you in performing the activities present in the book. It includes detailed steps that are to be performed by the students to complete and achieve the objectives of the book.
1. Vital Python – Math, Strings, Conditionals, and Loops
Activity 1: Assigning Values to Variables
Solution:
- We begin with the first step, where x has been assigned the value of 14:
x = 14
- Now we use the += operator to set x equal to x + 1 in the same step:
x += 1
- In this step, x is divided by 5, and the result is squared:
(x/5) ** 2
You should get the following output:
9.0
With this activity, you have learned how to perform multiple mathematical operations on a variable. This is very common in Python. For example, ...
Get The Python Workshop now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.