from IPython.display import HTML
HTML('<style>{}</style>'.format(open('../css/cowi.css').read()))
These exercises are tiny appetizers for next time.
Use a locally installed editor like Spyder or Visual Studio Code. If you want to try out coding without installing anything, try this online editor: https://www.onlinegdb.com/online_python_compiler
If you haven't done so yet, go ahead and create your first little program and type print('Hello world!')
.
Use Python to perform and print the result of these arithmetic operations:
Defining the expressions and running the code will not show any output. It has to be explicitly printed.
To print results, use the print()
function. The expression to be printed goes inside the parentheses.
Note: Exponentiation in Python is done by double asterisk
**
and not^
.
Save the results from Exercise 1 to variables called a
, b
, c
and d
, respectively. A variable is created an the assignment operator =
, just like in math.
Now, print the expressions from above by referencing the variable names instead.