0% found this document useful (0 votes)
15 views5 pages

Unit 1HomeWork

Uploaded by

dev.jinn221
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)
15 views5 pages

Unit 1HomeWork

Uploaded by

dev.jinn221
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
You are on page 1/ 5

Part I:

a. If you are trying to print your name, what happens if you leave out one of
the quotation marks or both, and why?
If I try to call python print built-in function without quotation marks, it will
certainly raise an error because Python follows strict syntax rules to translate the
codes into machine instructions. When the syntax is incorrect, Python interpreter
cannot parse it properly and will raise an error.

b. What is the difference between * and ** operators in Python? Explain with


the help of an example.
“*” is used to multiply a number. For example (2 x 2).

On the other hand, “**” is used for exponentiation. Check the following picture.
When you use “”, it works as (2x3). Moreover, “**” works as (2x2x2).

c. In Python, is it possible to display an integer like 09? Justify your answer.


No, it is not possible to display an integer like 09 in Python.In Python, integer
literals cannot have leading zeros unless they represent an octal number.

d. Run the commands type('67') and type(67). What is the difference in the
output and why? In Python, type built-in function is used to check the type of a
variable or value. In the first picture, when we insert 67 into quotation marks,
Python treats it as string. Everything in the quotation will be string type. On the
other hand, without quotation marks, Python will treat it as integer type.
Part II:

a. To multiply your age by 2 and display it. For example, if your age is 16,
so 16 * 2
= 32.
Ans:

b. Display the name of the city, country, and continent you


are living in. Ans:

c. To display the examination schedule (i.e., the starting and the ending
day) of this term.
Ans:

d. Display the temperature of your country on the day the assignment is


attempted by you
Ans:

Through the experiments in Part 1 and Part 2, I gained a deeper


understanding of Python’s syntax, data types, and common programming
practices. In Part 1, I explored frequently occurring errors and observed how
Python handles different types of mistakes. For example, leaving out one or
both quotation marks when printing a string results in a `SyntaxError`. This
taught me that Python relies heavily on proper syntax to distinguish between
strings and other types of data. Additionally, I learned the difference
between the `*` and `**` operators. While `*` is used for basic multiplication,
`**` is the exponentiation operator, allowing for efficient power calculations.
Furthermore, I ### Summary of What I Learned in Part 1 and Part 2
Through the experiments in Part 1 and Part 2, I gained a deeper
understanding of Python’s syntax, data types, and common programming
practices. In Part 1, I explored frequently occurring errors and observed how
Python handles different types of mistakes. For example, leaving out one or
both quotation marks when printing a string results in a `SyntaxError`. This
taught me that Python relies heavily on proper syntax to distinguish between
strings and other types of data. Additionally, I learned the difference
between the `*` and `**` operators. While `*` is used for basic multiplication,
`**` is the exponentiation operator, allowing for efficient power calculations.
Furthermore, I discovered that integers like `09` cannot be directly
represented in Python due to syntax rules that disallow leading zeros,
ensuring clarity and consistency in numeric representation. Lastly, the
`type()` function demonstrated how Python identifies the type of a value,
such as distinguishing between a string (`'67'`) and an integer (`67`).

In Part 2, I applied programming concepts to solve practical problems. I


wrote a program to multiply my age by 2, which reinforced my
understanding of basic arithmetic operations in Python. Displaying
information such as my city, country, and continent helped me practice
working with strings and variables. Creating a program to display the
examination schedule provided insight into handling date strings, while
displaying the temperature of my country on the assignment date
highlighted how Python can be used for dynamic data presentation.

Overall, these experiments reinforced the importance of attention to detail in


Python syntax and deepened my understanding of fundamental
programming concepts. They also showed how Python can be used for real-
world applications, from simple arithmetic to presenting meaningful
information.

You might also like