Computer Networking > EXAM > CS 1101 Programming Fundamentals Final Exam (All)
CS 1101 Programming Fundamentals Final Exam 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 without 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 ANS: [Show More]
Last updated: 4 months 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
Jun 06, 2021
Number of pages
4
Written in
This document has been written for:
Uploaded
Jun 06, 2021
Downloads
0
Views
237
In Scholarfriends, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.
We're available through e-mail, Twitter, Facebook, and live chat.
FAQ
Questions? Leave a message!
Copyright © Scholarfriends · High quality services·