Professional Documents
Culture Documents
PART ONE
If you print the string in python after leaving out one or both quotation marks then it will show an
error because in python strings are declared by using both quotation marks of single or double-quotes.
This is because it will be hard to determine the end or the beginning of the string.
To print a string list without quotes, use the expression '[' + ', '.join(lst) + ']' to create a single string
representation of the list without the quotes around the individual strings.
Here’s an example:
# Print List
print(s)
# [1, 2, 3]
2. What is the difference between * and ** operators in Python?
According to the course syllabus, the operator ** performs exponentiation; that is, it raises a number to
a power: >>> 6**2 + 6 will give you a result of 42 whiles the operator * is multiplication
3. >>> 09
leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
>>> type('67')
<class 'str'>
>>> type(67)
<class 'int'>
In these results, the word “class” is used in the sense of a category; a type is a category of values. Not
surprisingly, integers belong to the type int, strings belong to str, and strings are in quotation marks
according to the course syllabus.
PART 2
a. >>> 36*2
To multiply numbers in Python, we use the multiplication operator *. It is made up of just an
asterisk. If it appears between two numbers in Python, those numbers will multiply each other.
If we type 36 * 2 in the Python Interactive Shell, we will get 72 as the output. It does not matter
if these numbers are of different types, they can still multiply each other and give an output.
According to Django Central, Multiplication in Python is done by ( * ) operator, Then the result is
saved in the product variable and printed out using string formatting. However, the more
memory-efficient way to perform a multiplication in Python is by not using any variables at all it
can be done in a line, but it can make the code hard to read