Python- Review- Lesson no-2

Good Morning Dear Students



The correct responses  of the worksheet shared yesterday are as follows (in Maroon color):

1. Python is A high level language.
2.Python uses an interpreter.
3. Following are true for Python
  • Is simple
  • Platform independent and portable
  • Has a huge Library
4. Following are terms related to Python
  • Keywords
  • operators
  • punctuators
5. Keywords are
  • are special words which are reserved by Python .
  • are not allowed to be used as variables in Python.
  • are case-sensitive.

I hope you have a better understanding of the basic concepts of Python now.
______________________________________________________________________________
By the end of this session, you will be able to

  • Define the term "Identifiers"
  • Identify the rules to define identifiers
  • Define identifiers as per the need of the program.
  • Identify VALID and INVALID identifiers
___________________________________________________
Today our focus will be the concept of identifiers.
(Please take down the following concepts in your registers):

As you know that identifiers are 
  • very important in programming
  •  the building blocks of a program.
  •  So we need to create them wisely.
 RULES to follow while defining identifiers 
1.   
      1.  Identifiers can be a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an underscore _ Names like myClassvar_1 and print_this_to_screen, all are valid example.
1     2.  An identifier cannot start with a digit. eg. 1variable is invalid, but variable1 is perfectly fine.
2     3.    Keywords cannot be used as identifiers. eg. print cannot be used as an identifier. 
3    4.    We cannot use special symbols like !@#$% etc. in our identifier. The only symbol allowed is the underscore i.e. "_" eg. var_1
4     5.  An identifier can be of any length.


Things to Remember
1. Python is a case-sensitive language. This means, Variable and variable are not the same. Always name identifiers that make sense.
2. While, c = 10 is valid. Writing count = 10 would make more sense and it would be easier to figure out what it does even when you look at your code after a long gap.
3. Multiple words can be separated using an underscore, this_is_a_long_variable.


The following are some VALID identifiers:


MyFile
MYFILE
 CHK
 Z2t0Z29
DATE9_7_77
 _DS
 FILE13
HJI3_JK





The following are some INVALID identifiers( along with the reason):

DATA-REC contains special character – (hyphen) (other than A-Z,a-z,_(underscore))
 29CLCTstarting with a digit
 break - reserved word
 My.file – contains special character dot (.)
EXERCISE
Q1. Find whether the following Python identifiers are valid or not. Give reasons, if not valid:
   1.      happy_10
2.      For
3.      for
4.      10find
5.      Count
6.      Count 1
7.      cout@1
8.      1count
9.      Count_1
10.  if
11.  if#
12.  while
13.  while 2
14.  while_2
15.  while.nd
16.  while2

Please do the above exercise in your notebook. We will discuss the answers tomorrow.

Comments

  1. Good Morning. Please mark your attendance as you come.

    ReplyDelete
  2. good morning mam
    ashish -present

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Good morning ma'am

    EMMANUEL _ present

    ReplyDelete
  6. Mam I 've finished my work
    -ashish

    ReplyDelete
  7. Are there any doubts. This is a very important concept. Tomorrow we will start building the programs

    ReplyDelete
  8. There was some technical glitch because of which I couldnt see the comments. From tom pls mark your presence as u join class.

    ReplyDelete
  9. Also, all written work to be done in the register including the solution of the online test. We may not get time to revise all the topics we are doing now.

    ReplyDelete

Post a Comment

Popular posts from this blog

HOLIDAY HW