Python:
Python is a programming language.
Python can be used on a server to create web applications.
Features of python
- It is interpreted based language.
- python is a open source and light weighted language.
- It's platform is independent.
- It is object oriented programming language(OOPs).
- It is case sensitive.
Python data types
Variables can store data of different types, and different types can do different things.
Python has the following data types built-in by default, in these categories:
Text Type: | str |
Numeric Types: | int , float , complex |
Sequence Types: | list , tuple , range |
Mapping Type: | dict |
Set Types: | set , frozenset |
Boolean Type: | bool |
Binary Types: | bytes , bytearray , memoryview |
Setting the Data Type
In Python, the data type is set when you assign a value to a variable:
Example | Data Type | |
---|---|---|
x = "Hello World" | str | |
x = 20 | int | |
x = 20.5 | float | |
x = 1j | complex | |
x = ["apple", "banana", "cherry"] | list | |
x = ("apple", "banana", "cherry") | tuple | |
x = range(6) | range | |
x = {"name" : "John", "age" : 36} | dict | |
x = {"apple", "banana", "cherry"} | set | |
x = frozenset({"apple", "banana", "cherry"}) | frozenset | |
x = True | bool | |
x = b"Hello" | bytes | |
x = bytearray(5) | bytearray | |
x = memoryview(bytes(5)) | memoryview |
Python character set -
Character set is a set of valid characters that a language can recognise, character can be applied Alphabet (a-z), (A-Z), Number (0-9) and special symbol like ,."(); etc python supports unicode.
Tokens
The smallest individual unit in a program is known as a token or lexical unit. The five types of tokens available in python:
- Keywords : int, if, elif, for, etc (Reserve word).
- Identifier.
- Literal or constant .
- Separates or punctuators.
The naming rule of identifiers.
- The first character can be alphabets (A - Z) or underscore.
- On words character can be alphabets (A - Z), No (0 - 9), or underscore.
- No , special character is allowed other than underscore.
- Keywords cannot be taken as identifiers.
- Space is not allowed.
- Literals : Special literals (none constant).
- Punctuators or Separators : . # , : ; [ ] () {} etc.
Literals constant
- String literal
- Boolean: True and false (condition wise).
- Numeric: Integer (1,43,20) and Float (10.2,4.5)
An integer is colloquially defined as a number that can be written without a fractional component. For example, 21, 4, 0 etc
Floating it's a fundamental data type built into the compiler that's used to define numeric values with floating decimal points. for example 10.2, 1.1, 24.1 etc
String literals are inclosed with in single code, double court, or triple code.
here two types of line which are following-
- single line .
- Multiple line.
single line 'smash'
"smash"
"'smash"'
Multiple line line string can be created by:
- Adding a back slash at the end of each line and finally by using single code.
- Typing the text in triple code.
for\
beginners"'
Operators
Arithmetic Operator
- Unary Operators : eg -a, -10.
- Binary Operators : +, -, *, /, //, %.
0 Comments