Assignment 1
Assignment 1
Question a:
If you leave out one or both of the quotation marks while trying to print your name in Python,
you will encounter a SyntaxError. This is because Python expects strings to be enclosed in either
Question b:
In Python, the * operator is used for multiplication, while the ** operator is used for
exponentiation
Question c:
In Python, it's not possible to display an integer like 09 because numbers starting with 0 are
treated as octal (base 8). Since 9 is not a valid octal digit, it would result in a SyntaxError. To
display leading zeros with integers, you would need to convert the integer to a string and then
format it accordingly
Ref: (Python Software Foundation, 2020).
Question d:
When you run type('67'), it will return the type str because you've enclosed the digits in single
quotes, making it a string. When you run type(67), it will return the type int because it's a plain
Part 2:
Question a:
To multiply your age by 2 and display it in Python, you can use the following code
age = 16
result = age * 2
print(result)
Question b:
To display the name of the city, country, and continent, you can define variables for each and
print them
city = "New York"
country = "USA"
print("City:", city)
print("Country:", country)
print("Continent:", continent)
Question c:
To display the examination schedule, you can define variables for the starting and ending day
start_date = "2023-12-10"
end_date = "2023-12-20"
print("Examination Schedule:")
To display the temperature of Pakistan on the day I attempted this assignment, I included real-
time temperature data, with Pakistan experiencing a temperature of 37 degrees Celsius on this
particular day. I used this data in my Python program to provide an accurate temperature reading.
country = "Pakistan"
temperature = 37
References:
Python Software Foundation. (2020). Python 3.8.3 documentation: The Python Language
Reference. https://docs.python.org/3/reference/index.html