Assignment CS1101- Pgrogramming Fundaments Week 1 PDF

Title Assignment CS1101- Pgrogramming Fundaments Week 1
Author Sanyaolu Horladypupo
Course Programming Fundamentals
Institution University of the People
Pages 2
File Size 68 KB
File Type PDF
Total Downloads 76
Total Views 138

Summary

Programmi Fundamental Assignment Week 1. For future references...


Description

PART 1 1. Example Python Code: >>> print (Hello, World!) File "", line 1 print (Hello, World!) ^ SyntaxError: invalid syntax Answer: It indicated here that I should have a standard input on line 1, indicating an error in the source code translation. Just as I omitted the colon at the end of the def statement yielded the redundant message of syntax error. 2. Example Python Code: >>> +2++2 >>> -2++2 0 >>> -2--2 0 >>> -2+-2 -4 >>> -2-+2 -4 Answer: It gave the correct answer/prompt without error. This is due to the 3. Example Python Code: print (02) File "", line 1 print (02) ^ SyntaxError: The leading zeros in decimal integer and/or octal numeral system are not permitted; instead the use of an 0o (Zero with letter o) prefix for octal integers >>> Answer: Because Python 3 does not permit leading Zeroes as/in decimal integer unlike Python 2, which allows it but is differentiated in Python 3 4. Example Python Code: >>> 22 22 Answer: If two values are placed together without space or an operator in between them, the said output would render the same value as the initial/command inputted.

PART 2 1. Example Python Code: >>> print 'Hello, World!' File "", line 1 print 'Hello, World!' ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, World!')? >>> ANSWER: parentheses are used for order of operations, or order of evaluation, and each bracket type has a specific function in Python programming. Also, in Python 3, print is not a

statement. It is a function. I must call a function using parentheses if I want to run it successfully. 2. Example Python Code: >>> print (4-+4) 0 >>> ANSWER: The answer it gives is accurate as to addition 0 3. Example Python Code (Syntax):>>> print (Hello, World!) File "", line 1 print (Hello, World!) ^ SyntaxError: invalid syntax Answer: Syntax errors are produced by Python because it can’t translate the source code. Python programming indicates that there is something wrong with the syntax of the program. Just as I omitted the colon at the end of the statement....


Similar Free PDFs