Thursday, May 6, 2021

String

 String (data type) : 

Strings are arrays of bytes representing Unicode characters.

》A string is a collection of one or more characters put in a single quote, double-quote or triple quote. In python there is no character data type, a character is a string of length one. 

It is represented by str class.

Example :-

1.var1 = 'Hello World!' .

2. var2 = 'RhinoPython' 

  •  print var1[0] # this will print the first character in the string an `H`

  • print var2[1:5] # this will print the substring 'hinoP`

Simple question for you :

Find output  for following code 

>>>String = 'Python programming'
>>>Print(string[3:7])
       
Options

1. Error
2. Python p
3. hon program
4.none

Number

Number (data type)

       1.Int  = Signed integer 
          Ex :- a=10

       2.Long = (L) long integers, they can also be                represented in octal and hexadecimal.
          Ex :- b= 345L

       3.Float = (.)floating  point and real values.
          Ex :- c= 45.67

       4.Complex = (J) contains integer in the                      range  0 to 255
           Ex :- d = 3.14J

 type() function is used to find  data type in   Python

Example  :-
                  a= 10
                  type(a)
                  b= 231L
                  type(b)
                  c= 48.23
                  type(c)
                  d = 45.7J
                  type(d)





Data type

 Build-in data types 

Text type : str

Numeric types : int ,float, complex

Sequence type : list, tuple, range

Mapping type : dictionary 

Set type : set ,frozenset

Boolean type : bool

Binary type : bytes , bytearray , memoryview


Most commonly used :

  1. Numbers
  2. String
  3. List
  4. Tuple
  5. Dictionary 


Wednesday, May 5, 2021

Python building blocks

Python Identifiers


Python Identifiers are user-defined names to represent a variable, function, class, module or any other object. If you assign some name to a programmable entity in Python, then it is nothing but technically called an identifier.


Python language lays down a set of rules for programmers to create meaningful identifiers.


Guidelines for Creating Identifiers in Python.

1. To form an identifier, use a sequence of letters either in lowercase (a to z) or uppercase (A to Z). However, you can also mix up digits (0 to 9) or an underscore (_) while writing an identifier.

For example – Names like shapeClass, shape_1, and upload_shape_to_db are all valid identifiers.

2. You can’t use digits to begin an identifier name. It’ll lead to the syntax error.

For example – The name, 0Shape is incorrect, but shape1 is a valid identifier.

3. Also, the Keywords are reserved, so you should not use them as identifiers.

4. Python Identifiers can also not have special characters [‘.’, ‘!’, ‘@’, ‘#’, ‘$’, ‘%’] in their formation. These symbols are forbidden.

5. Python doc says that you can have an identifier with unlimited length. But it is just the half truth. Using a large name (more than 79 chars) would lead to the violation of a rule set by the PEP-8 standard. It says.Limit all lines to a maximum of 79 characters.


Question :

You are interested in Python....🐍.........

.

Features of python

 Features of Python

Python is Interpreted − Python is processed at runtime by the interpreter. You do not need to compile your program before executing it. 

Python is Interactive − You can actually sit at a Python prompt and interact with the interpreter directly to write your programs.

Python is Object-Oriented − Python supports Object-Oriented style or technique of programming that encapsulates code within objects.

Python is a Beginner's Language − Python is a great language for the beginner-level programmers and supports the development of a wide range of applications from simple text processing to WWW browsers to games.

Question for you:

You like python programming ?

Basics of python

History of python 


  • Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language.

  •  It was created by Guido van Rossum during 1985-1990. Like Perl, Python source code is also available under the GNU General Public License (GPL).

  • Did you like .......................

String

  String (data type) :  》 Strings are arrays of bytes representing Unicode characters. 》A string is a collection of one or more characters p...