Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

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

When we were trying to performed 02 in python it gives us a syntax error:


Invalid Token.
As it is against the rule or language of python 3.

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:

Downey, A. (2015). Think Python: How to think like a computer scientist. Green


Tea Press. This book is licensed under Creative Commons Attribution-
Noncommercial 3.0 Unported (CC BY-NC 3.0).

1. Type of the value

>>>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.

2. The type of value has changes if they are in quotation marks

>>>Type(‘2’)
<class ‘str’>

>>> type(’42.0’)

<class’str’>

They are all string types.

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,000,000 if the values are the same 000, it wil be come 0

(1,0,0)

>>>1, 123,456,789

(1,123,456,789)

>>>>

>>>1,222,333

(1,222,333)

>>>

the fol

You might also like