Professional Documents
Culture Documents
Learning Journal Assignment
Learning Journal Assignment
Part 1
1. If you are trying to print a string, what happens if you leave out one of
the quotation marks, or both?
-Printing a string without one quotation marks will encounter a syntax error.
While printing without both quotation marks will print the value as it is like for
example:
>>>print (123)
Output 123
2. You can use a minus sign to make a negative number like -2.What
happen for each of the following?
>>>2++2
4
>>>2- - 2
4
>>>2+-2
0
>>>2-+2
0
3. In math notation,
leading zeros are OK, as
in 02. What happens if
you try this in
Python?
3. In math notation , leading zeros are OK , as in 02. What happen if you try
this in python?
>>> 02
File "<stdin>", line 1
02
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for
octal integers
>>> print('02")
File "<stdin>", line 1
print('02")
^
Syntax Error: unterminated string literal (detected at line 1)
>>> 2+02
File "<stdin>", line 1
2+02
^
Syntax Error: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal
integers
4. What happen if you have two values with no operator between them?
When we enter two values in python for example:
Print (5 5) without operators
>>> (5 5)
File "<stdin>", line 1
(5 5)
^^^
Syntax Error: invalid syntax. Perhaps you forgot a comma?
It gives a syntax error; “invalid syntax” that is not compatible in python
language or against the rule of python.
PART 2
Next, describe at least three additional Python experiments that you tried
while learning Chapter 1. Show the Python inputs and their outputs,
and explain what you learned from the results of each example.
Reference:
>>>type(2)
<class ‘int’>
>>>type(42.0)
<class ‘float’>
>>>type(‘hello, world!’)
<class ‘str’>
A value is one of the basic things a program works with , like a letter or a
number. It belongs to different types :2 is an integer , 42.0 is a floating-
point number and ‘Hello world’ is a string.
>>>Type(‘2’)
<class ‘str’>
>>> type(’42.0’)
<class’str’>
3. When you type a large integer, you might be tempted to use between
groups of digits , as in 1,000,000. This is not a legal integer in python:
(1,0,0)
>>>1, 123,456,789
(1,123,456,789)
>>>>
>>>1,222,333
(1,222,333)
>>>
the fol