0% found this document useful (0 votes)
11 views3 pages

Programming Assignment Unit 1

The document outlines common Python mistakes and their explanations, such as missing quotation marks and the difference between multiplication and exponentiation. It also includes simple Python programs demonstrating basic syntax and operations. The learning outcomes emphasize understanding Python's syntax rules, data types, and the importance of differentiating between strings and integers for effective programming.

Uploaded by

Joseph Njovu
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)
11 views3 pages

Programming Assignment Unit 1

The document outlines common Python mistakes and their explanations, such as missing quotation marks and the difference between multiplication and exponentiation. It also includes simple Python programs demonstrating basic syntax and operations. The learning outcomes emphasize understanding Python's syntax rules, data types, and the importance of differentiating between strings and integers for effective programming.

Uploaded by

Joseph Njovu
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

Programming Assignment Unit 1

PART 1: LEARN FROM YOUR MISTAKES

a) Missing quotation marks:

Code:

print(Joseph)

Output:

NameError: name 'Joseph' is not defined

Explanation:

Strings in Python must be enclosed in quotation marks. Without quotes, Python treats the
text as a variable name.

b) Difference between * and **:

Code:

print(3 * 4)

print(3 ** 4)

Output:

12

81

Explanation:

The * operator performs multiplication, while ** performs exponentiation.


c) Integer 09:

Code:

print(09)

Output:

SyntaxError: leading zeros in decimal integer literals are not permitted

Explanation:

Python does not allow leading zeros in decimal integers.

d) type('67') vs type(67):

Code:

print(type('67'))

print(type(67))

Output:

<class 'str'>

<class 'int'>

Explanation:

'67' is a string, while 67 is an integer.

PART 2: PYTHON PROGRAMS

a) Age multiplied by 2:
Code:

age = 20

print(age * 2)

b) Location display:

Code:

print("Lusaka, Zambia, Africa")

c) Examination schedule:

Code:

print("Exams start on 1st June and end on 15th June")

d) Temperature:

Code:

print("Temperature in Zambia today is 25°C")

LEARNING OUTCOMES:

This assignment helped me understand Python syntax, data types, arithmetic operations,
and error handling. I learned that Python is strict with syntax rules such as quotation marks
and numeric formats. I also learned how Python differentiates between strings and integers,
which is crucial for debugging programs. Simple programs demonstrated how variables
store data and how output is displayed using the print() function. These foundational
concepts are essential for writing correct and efficient Python programs.

References
Downey, A. (2015). Think Python: How to think like a computer scientist. Green Tree Press.

You might also like