0% found this document useful (0 votes)
3 views1 page

Ch.7 Python Notebook Answers

Chapter 7 discusses key features of Python, highlighting its simple syntax and lack of requirement for semicolons or curly braces. It outlines rules for naming variables, emphasizing the use of letters, digits, and underscores while prohibiting special characters. The chapter also explains the purpose of comments in Python and the use of the int() function for converting values to integers.

Uploaded by

himothy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Ch.7 Python Notebook Answers

Chapter 7 discusses key features of Python, highlighting its simple syntax and lack of requirement for semicolons or curly braces. It outlines rules for naming variables, emphasizing the use of letters, digits, and underscores while prohibiting special characters. The chapter also explains the purpose of comments in Python and the use of the int() function for converting values to integers.

Uploaded by

himothy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chapter 7: Introduction to Python- Notebook Answers

[Link] the following questions:


a. List any two features of Python that make it a better choice compared to other
languages.
Ans.
 The instructions in Python are simple. They are more or less similar to the
words used in the English language. This has increased its popularity.
 Python does not require a semicolon or curly braces to end a statement, unlike
many other languages.
b. List the rules to be followed while selecting a name for the variable.
Ans.
 A variable name can only contain alphabets, numeric digits and underscores
(A-Z, a-z, 0-9, _ ). You cannot use special characters such as!.@,#,$,% etc. in a
variable name.
 A variable name must start with either a letter or an underscore. It cannot
start with a numeric digit or any other character.
c. What are comments used for in Python? How do you indicate a comment in a
program?
Ans:
The notes that we add in our program to help us, or others using our program to
understand it are called as comments. Comments are ignored by a computer when
the program is executed. In Python, a comment starts with a ‘#’.
Comments can also be used to temporarily disable a command that you do not want
to execute, without deleting it from the program.
d. Explain the use of the int( ) function with an example.
Ans: The int( ) function in Python is used to convert a given value into an integer. It
can take a number in string form or a float and convert it to an integer.
Example: age=int(age)
Here in the example, age is a variable which can hold any values like integer, float etc.
The int ( ) converts age into integer type.

You might also like