-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path4_Variables, DataTypes & Typecasting.py
More file actions
39 lines (25 loc) · 1.19 KB
/
4_Variables, DataTypes & Typecasting.py
File metadata and controls
39 lines (25 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'''
1. Variables -
a) A variable name can contain alphabets,digits, and underscores.
b) A variable name can only start with an alphabet and underscore.
c) It can't start with an digit.
d) No white spaces are allowed.
e) Reserved keywords should not be used.
2. Data Types (Primitive) -
a) Integers - <class 'int'>
b) Floating point numbers. - <class 'float'>
c) Strings - <class 'string'>
d) Boolean - <class 'bool'>
e) None -
3. Data Types (Data Collection Types) -
a) Lists
b) Tuples
c) Sets
d) Dictionaries
4. Typecasting -
a) Typecasting is the way to change one data type of any data or variable to another datatype, i.e., it changes the data type of any variable to some other data type.
b) There are many functions to convert one data type into another type :-
str() - this function allows us to convert some other data type into a string.
int() - this function allows us to convert some other data type into an integer. For example, str("34") returns 34 which is of type integer (int)
float() - this function allows us to convert some other data type into a floating-point number, i.e., a number with decimals.
'''