0% found this document useful (0 votes)
8 views7 pages

Programming Assignment Unit 1

The document outlines a programming assignment for CS 1101, focusing on Python fundamentals such as syntax errors, variable types, and arithmetic operations. It includes explanations of common mistakes, the use of operators, and practical programming tasks that reinforce learning through real-life applications. The author reflects on their learning experience, emphasizing the importance of testing and debugging in understanding Python.

Uploaded by

harrygamtel
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)
8 views7 pages

Programming Assignment Unit 1

The document outlines a programming assignment for CS 1101, focusing on Python fundamentals such as syntax errors, variable types, and arithmetic operations. It includes explanations of common mistakes, the use of operators, and practical programming tasks that reinforce learning through real-life applications. The author reflects on their learning experience, emphasizing the importance of testing and debugging in understanding Python.

Uploaded by

harrygamtel
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

Name: Harry Joof

Course: CS 1101- Programming Fundamentals


Date: September 11, 2025

Part 1: Learn from Your Mistakes

A. What happens if you leave out one or both quotation marks when trying to print your
name?

Code:

Expected Errors:

 Missing one quote:

 Missing both quotes:

Explanation:
When printing strings, quotation marks tell Python where the string starts and ends. If you
leave out a quote, Python cannot determine the string boundary and throws a SyntaxError. If
both quotes are missing, Python assumes it's a variable. Since John is undefined.

B. What is the difference between * and ** operators in Python?

Code:

Expected Output:

Explanation:

 * multiplies two numbers.


 ** raises the number on the left to the power of the number on the right.

C. Is it possible to display an integer like 09 in Python

Code:
Expected Output:

Explanation:

In Python 3, numbers with a leading zero (like 09) are not allowed, because it conflicts with octal
(base-8) notation. To represent zero-prefixed numbers, use strings (e.g., "09") instead of integers.

D. What is the difference between type('67') and type(67)?

Code:

Expected Output:

Explanation:

 '67' is enclosed in quotes, so it's a string (str).


 67 is an integer literal with no quotes, so it's an integer (int).

Understanding the difference is important because strings and integers behave differently in
calculations and functions.
Part 2: Python Program Tasks

A. Multiply your age by 2 and display it

Code:

Expected Output:

Explanation:

This code uses a simple variable assignment and multiplication operation. It demonstrates how
Python handles arithmetic and variables.

B. Display your city, country, and continent

Code:

Expected Output:
Explanation:

This program displays string data stored in variables. It reinforces the use of string literals and
how print() works with text formatting.

C. Display the examination schedule

Code:

Expected Output:

Explanation:

This shows how you can store and present dates using strings. It's a basic example of how
Python can be used to manage schedule data.
D. Display the current temperature of your country

Code:

Expected Output:

Explanation:

This code uses a string to represent temperature. In more advanced cases, you could fetch live
data using an API, but here we use a static string value for simplicity.

What I have learned from the results of each experiment in part 1& 2 questions.

This assignment helped reinforce my understanding of Python basics, including syntax rules,
variable types, and arithmetic operations. In Part 1, I learned that missing or unmatched
quotation marks result in syntax errors, and that variable names must be defined before use. The
difference between string and integer types became very clear through the type() function,
especially when dealing with data that may look numeric but is actually textual (e.g., '67' vs. 67).
I also understood why Python does not allow integers like 09 due to historical issues with octal
representation.

In Part 2, I practiced writing actual programs that represent real-life use cases. Multiplying age
by two was a simple way to use variables and arithmetic. Displaying the city, country, and
continent taught me about string handling. The exam schedule program showed how Python can
represent event data, while the temperature display demonstrated how to use text to represent
environment information. Each task helped solidify my comfort with writing basic Python
syntax, understanding types, and formatting output.

From this, I also realized the importance of testing and debugging—mistakes helped me
understand Python’s rules better than simply reading. Going forward, I feel more confident in
creating simple programs, identifying errors, and correcting them efficiently.
References:

Downey, A. (2015). Think Python: How to think like a computer scientist (2nd ed.). Green Tree
Press. [Link]

Python Software Foundation. (n.d.). Using Python on Windows.


[Link]

Python Software Foundation. (n.d.). Using Python on Unix platforms.


[Link]

You might also like