Keywords:
• The keywords have predefined meaning assigned by the Python
  Complier. The keywords are also called as reserved word.
• All keywords are written in lower case alphabets. The Python
  keywords are:
• 4. Variable: Is a program element, whose value changes during
  the execution of the program. Unlike other programming
  languages, Python has no command for declaring a variable. A
  variable is created the moment you first assign a value to it. Eg.
  x=5; y=”kvn” Variables do not need to be declared with any
  particular type and can even change type after they have been
  set.
• 5. Constants: Constant is a program element, while execution of a
  program the value does not change. A constant gets stored in a
  memory location but the address of the location is not accessible
  to the programmer
Working with Python Python Code Execution:
• Python’s traditional runtime execution model:
• Source code you type is translated to byte code, which is then run by the
  Python Virtual Machine (PVM). Your code is automatically compiled, but
  then it is interpreted. Source Byte code Runtime Source code extension is
  .py Byte code extension is .pyc (Compiled python code).
There are two modes for using the Python
interpreter:
• • Interactive Mode
• • Script Mode
Running Python in script mode:
• programmers can store Python script source code in a file with the .py
  extension, and use the interpreter to execute the contents of the file. To
  execute the script by the interpreter, you have to tell the interpreter the
  name of the file. For example, if you have a script name MyFile.py and you're
  working on Unix, to run the script you have to type: python MyFile.py
  Working with the interactive mode is better when Python programmers deal
  with small pieces of code as you can type and execute them immediately,
  but when the code is more than 2-4 lines, using the script for coding can
  help to modify and use the code in future.
Elements of Python
• A Python program is a sequence of definitions and commands
  (statements)
• Commands manipulate objects
• Each object is associated with a Type
• Type:
         • A set of values
         • A set of operations on these values
• Expressions: An operation (combination of objects and operators)
Nov-22                                     Programming               6
Data types:
• The data stored in memory can be of many types.
• For example, a student roll number is stored as a numeric value and his or
  her address is stored as alphanumeric characters. Python has various
  standard data types that are used to define the operations possible on
  them and the storage method for each of them.
• Int: Int, or integer, is a whole number, positive or negative, without decimals, of
  unlimited length.
• >>> print(24656354687654+2)
• 24656354687656
• >>> print(20) 20
• Float: Float, or "floating point number" is a number, positive or negative,
  containing one or more decimals. Float can also be scientific numbers with an "e"
  to indicate the power of 10.
• >>> y=2.8
• >>> y 2.8
• >>> y=2.8
• >>> print(type(y))
• >>> type(.4) >>> 2
• Boolean: Objects of Boolean type may have one of two values, True or
  False:
• >>> type(True)
• >>> type(False)
• String:
• 1. Strings in Python are identified as a contiguous set of characters
  represented in the quotation marks. Python allows for either pairs of
  single or double quotes.
• • 'hello' is the same as "hello".
• • Strings can be output to screen using the print function. For example:
  print("hello").
• >>> print("mrcet college") mrcet college
• >>> type("mrcet college")
         Types in Python
• int
    • Bounded integers, e.g. 732 or -5
• float
    • Real numbers, e.g. 3.14 or 2.0
• long
    • Long integers with unlimited precision
• str
    • Strings, e.g. ‘hello’ or ‘C’
Nov-22                    Programming          10
Escape Characters Following table is a list of escape or
non-printable characters that can be represented with
backslash.
• An escape character gets interpreted; in a single quoted as well as double
  quoted strings.
Operator and Operand:
• Operators are special symbols which represents computation. They are
  applied on operand(s), which can be values or variables. Same operator can
  behave differently on different data types. Operators when applied on
  operands form an expression. Operators are categorized as Arithmetic,
  Relational, Logical and Assignment. Value and variables when used with
  operator are known as operands.
   Input function
• The print function enables a Python program to display textual information
  to the user. Programs may use the input function to obtain information from
  the user. The simplest use of the input function assigns a string to a variable:
  x = input() The parentheses are empty because the input function does not
  require any information to do its job. usinginput.py demonstrates that the
  input function produces a string value.
• Demonstrates that the input function print('Please enter some text:')
  x = input() print('Text entered:', x) print('Type:', type(x)) Since user
  input always requires a message to the user about the expected
  input, the input function optionally accepts a string and prints just
  before the program stops to wait for the user to respond. The
  statement variable = input("Enter a value: ")