0% found this document useful (0 votes)
33 views4 pages

CS 1101-Learning Journal Unit 1

The document discusses Python experiments with strings, numbers, operators, and data types. It provides example code snippets and outputs to demonstrate what happens when quotation marks are missing from a print string, when different arithmetic operators are used, when leading zeros are used in a number, and when two values have no operator between them. It also shows additional experiments around multiplication, type checking, and exponents.

Uploaded by

Bevine ambita
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views4 pages

CS 1101-Learning Journal Unit 1

The document discusses Python experiments with strings, numbers, operators, and data types. It provides example code snippets and outputs to demonstrate what happens when quotation marks are missing from a print string, when different arithmetic operators are used, when leading zeros are used in a number, and when two values have no operator between them. It also shows additional experiments around multiplication, type checking, and exponents.

Uploaded by

Bevine ambita
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Part 1:

Exercise 1.1

If you are trying to print a string, what happens if you leave out one of the quotation marks or both
and why?

Answer:

Input: >>>> print (Hello’)

Output: Syntax Error: EOL while scanning string literal

Input: >>> print (Hello)

Output: Trackback (most recent call last):

File “<pyshell#5>”, line 1, in <module> print (Hello)

Name Error: name ‘Hello’ is not defined

Explanation: If we are trying to print a string but without a quotation marks one or both of them like
if we run this code >>> print (Hello’) it will give us an error Syntax Error: EOL while scanning string
literal Because “The quotation marks in the program mark the beginning and end of the text to be
displayed; they don’t appear in the result’s ( Downey, A. (2015).)

You can use a minus sign to make a negative number like -2. What happens for each of the following
and why? Input: >>> 2++2

Output : 4

Explanation: in the above statement we used the Arithmetic Operator which are the symbol used
fore Additions 2++2=4
Input: >>> 2 – 2

Output : 4

Explanation: in the above statement we used the Arithmetic Operator which are used for subtraction
2-2=4ti Because it is the rule of math whenever two minus comes together it will function of
addition like here

Input: >>> 2+-2

Output : 0

Explanation: in the above statement we have used the Arithmetic Operators It is the math rules
whenever plus (+) and the minus (-) comes together so it will be subtraction like heretics Input: >>>
2-+2

Output : 0

Explanation: in the above statement we have used the Arithmetic Operators The same explanation
as above

In math notation, leading zeros are OK, as in 02. What happens if you try this in Python and why ?

Answer: leading a zero such as 01 and 04 are defined as a syntax error like >>>print (02) it will give
us a syntax error according to python 3x, because it is not permitted in decimal integer literalist

Input: >>> print (02)

Output: Syntax Error: leading zeros in decimal integer literals are not permitted; use an Oo prefix for
octal integers

What happens if you have two values with no operator and a space in between them and why ?
Answer: if we run two values without any operator and having a space between these tow values so
it will give using error like for example if we run >>> print (23)in python3x it will return with an error
result, because there is no operators Input: >>> print (2 3)

Output: Syntax Error: invalid syntax

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.

Example.1:

Input: >>> print (2f13)

Output: 6

I have learnt that how to multiple in python so here I multiple 2 by 3 which give me in result 6 which
incorrect results

Example. 2:

Input: >>> type (2)

Output: <class 'int'>

I run this code so I learnt how to find the value. So here is integer valuate Example. 3: Input: >>>
print (2fifi3)

Output: 8

In this example I learnt the operator which is used fore number powers

You might also like