Computer Science > JOURNAL > CS 1101 Programming Fundamentals- Term2, 2019-2020 (All)
1. If you are trying to print a string, what happens if you leave out one of the quotation marks or both and why? ANS: In python we have integer, String, float data types all these initialized wit ... hout quotation except string the compiler ignore what ever come in between quotation because is referred as natural language, When trying print a string without “” the interpreter will consider it as an integer or double, when interpreter trying to interpret and found was a string not integer it print an error eg: >>> print (Abubakar) Traceback (most recent call last): File "<stdin>", line 1, in <module>NameError: name 'Abubakar' is not defined >>> in this example python recognized Abubakar as variable but is not defined anywhere in the code and that is why return error. let put quotation and see; >>> print ('Abubakar') Abubakar >>> now after putting quotation before and after string latter the out print without error, because its now recognized as string not integer nor variable. Let remove one quotation; >>> print (Abubakar') File "<stdin>", line 1 print (Abubakar') ^ SyntaxError: EOL while scanning string literal >>> “EOL (End of Line) error in python occurs when while scanning a string of a program the python hit the end of the line due to the following reasons: Missing Quotes for closing the string String Extends Past one Line”(STechies,2019) 2. you can use minus to get negative number like -2. What happen of each of the following? >>>2++2 >>>2—2 >>>2+-2 >>>2-+2 [Show More]
Last updated: 3 years ago
Preview 1 out of 4 pages
Buy this document to get the full access instantly
Instant Download Access after purchase
Buy NowInstant download
We Accept:
Can't find what you want? Try our AI powered Search
Connected school, study & course
About the document
Uploaded On
Nov 23, 2021
Number of pages
4
Written in
All
This document has been written for:
Uploaded
Nov 23, 2021
Downloads
0
Views
160
Scholarfriends.com Online Platform by Browsegrades Inc. 651N South Broad St, Middletown DE. United States.
We're available through e-mail, Twitter, Facebook, and live chat.
FAQ
Questions? Leave a message!
Copyright © Scholarfriends · High quality services·