Answer to Question #153143 in Python for Deladin

Question #153143

Type the statements below into your Python interpreter. For each statement, copy the output into your Discussion Assignment and explain the output. Compare it with any similar examples in the textbook, and describe what it means about your version of Python. 

>>> print 'Hello, World!'

>>> 1/2

>>> type(1/2)

>>> print(01)

>>> 1/(2/3)


1
Expert's answer
2020-12-29T14:43:49-0500
>>> print 'Hello, World!'
#the interpreter's response
>>>SyntaxError: unexpected indent
#in python ver 3 print() is a function
#the correct syntax would be
#print ('Hello, World!')
#print 'Hello, World!' will display
#Hello, World!  
#for example in python version 2.7
>>> 1/2
#the interpreter's response
>>>0.5
#division operator executed
#returned result is a floating point value
>>> type(1/2)
#the interpreter's response
>>><class 'float'>
#type() method returns class type of the argument
#in this case argument is the result of division
#in the previous example, it was indicated that the
#result of division is a floating point value
>>> print(01)
#the interpreter's response
>>> SyntaxError: leading zeros in decimal integer literals are not permitted
#in python, a leading zero is used to denote number systems
# as an example 0b - bin or 0x -hex
# value 01 interpreter interprets as possible user input error
>>> 1/(2/3)
#the interpreter's response
>>> 1.5
#the result of the division is displayed,
#taking into account the priority of the action in parentheses


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS