-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path05_data_types.py
More file actions
75 lines (64 loc) · 2.98 KB
/
Copy path05_data_types.py
File metadata and controls
75 lines (64 loc) · 2.98 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#======================================================================================
# DATA TYPES
#--------------------------------------------------------------------------------------
# Python automatically detect data types, so you don't need to declare it
# Data Types can change any time!
#======================================================================================
# Data Types
# ---------------------------------------------------
# No Value | Single value | Multi values |
# ---------------------------------------------------
# none | int,float, | list,set, |
# | str,bool | tuple, dict |
#----------------------------------------------------
#--------------------------------------------------------------------------------------
# Basic data types in python
#--------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------
# int: integer:whole number without decimals
#--------------------------------------------------------------------------------------
a = 10
print(a, type(a))
#--------------------------------------------------------------------------------------
# float: numbers with decimal points
#--------------------------------------------------------------------------------------
b = 3.15
print(b, type(b))
#--------------------------------------------------------------------------------------
# String: Represent text or a sequence of characters
# written inside single or double quotes
#--------------------------------------------------------------------------------------
c = "Hello" # str
d = 'Hi' # Str
e = "1234" # str
print(c, type(c))
print(d, type(d))
print(e, type(e))
#--------------------------------------------------------------------------------------
# Boolean: Can be either True or False
# used to handle logic and decision-making
# True or False are case-sensitive;they must start with a capital letter
f = True #bool
g = False #bool
print(f, type(f))
print(g, type(g))
#--------------------------------------------------------------------------------------
# none: means "no value", "nothing" or "unknown"
#--------------------------------------------------------------------------------------
h = None
print(h, type(h))
i = "" # str - Blank
j = " " # str - Empty Space
print(i, type(i))
print(j, type(j))
#--------------------------------------------------------------------------------------
# Summary
#--------------------------------------------------------------------------------------
# Each value has a data type (this helps python decide how to handle the value)
# It automatically detects data types
# Dynamic: Data Types can change anytime
# 3 Categories
# No value :- NoneType
# Singe Value :- int,str,bool,float,complex
# Multiple Values :- set,tuple,dict,list
# Values are objects of data type class