Homework
Try out these exercises at home. These are just examples. Try to find some more examples in the internet or just play around!
- Which Python version are you using?
- What is the type of an error that occurs when:
- You are quoring only one side of a string? (SyntaxError)
- You are trying to subtract a number from a string?
- You divide by zero?
- You try to use a variable that does not exist?
- You press Ctrl+C when a program asks for input (using the
input
function)?
- You put a space or tab before a statement?
- You do not close parenthesis?
- You are trying to use an exclamation mark as an operator
- What error occurs when you're trying to assign a string to a string?
- Not everything can be used as a variable name. Try the following, which ones can not be used as variable names? Why?
x
,
button4
,
34
,
3e4
,
turkey
,
$i
,
square-root
,
readme
,
readme.txt
,
shorterEdge
,
shorter_edge
,
NUMBER_OF_POINTS
,
_
,
π
,
True
,
_cache
,
__name__
,
while
.
- Some of the names above are valid, but not very good variable names. Which ones do you think are those?
- Which one of
shorterEdge
, shorter_edge
is a more correct name for a variable? Why? Try searching for PEP 8 variable names. What's a PEP 8?
- Try to write a program that calculates the surface and volume of a cube with edge = 2852 cm.
- Now change the program so that the user can enter the edge value.
Toto je stránka lekce z kurzu, který probíhá nebo proběhl naživo s instruktorem.