Unit 1.2
Unit 1.2
Unit 1.2
Subject
Introduction to Python
Unit 1.2
Prof. M. V. Tiwari
•Python Comments
Comments are any text to the right of # symbol and is mainly useful as notes for the reader of the
program.
Comments explain:
1. Assumptions
2. Important Decisions
3. Important Details
4. Problems you are typing to solve
•Identifier
Identifier is a name given to programming elements like variables, functions, strings, etc.
Identifier Rules:
1. Name can contain any combination of letters, Underscore ( _ ) and digits.
2. Name cannot begin with digit.
3. Names are case sensitive.
4. Keywords cannot be used as Indentifies.
•Data Types
Q 1) You develop a python application for your company. You want to add notes to your
code so other members will understand it. What should you do ?
For each of the following statements, select Yes if the statement is true else no.
Q 3) You create a function to calculate the power of a number by using Python Practice Test. You
need to ensure that the function is documented with comments. You create the following code. Line
numbers are included for reference only.
For each of the following statements, select Yes if the statement is true, otherwise select false.
Options :
Lines 01 through 04 will be ignored for syntax checking Yes / No
The pound sign (#) is optional for line 2 and 3 Yes / No
The string in line 6 will be interpreted as a comment Yes / No
Line 7 contains on inline comment. Yes / No
DEPARTMENT OF ELECTRONICS & TELECOMMUNICATION ENGINEERING PROF. M. V. Tiwari
2SAEKNT : Introduction to Python P R M I T & R ,B A D N E R A
Options :
Q8) Which of the following is invalid identifier rules ? Select all that apply.
A)Name can contain $ B) Name can begin with digit
C) Keyword cannot be used as identifier D) Names are case sensitive
DEPARTMENT OF ELECTRONICS & TELECOMMUNICATION ENGINEERING PROF. M. V. Tiwari
2SAEKNT : Introduction to Python P R M I T & R ,B A D N E R A
A = 2;
Minor = False;
Name = “Contosa”;
Weight = 123.5;
Zip = “81000”
What are the data types of the above declaration ?