|
| 1 | +# # DataTypes in python |
| 2 | +# # int |
| 3 | +# i = 30 |
| 4 | +# print(i) |
| 5 | +# print(type(i)) |
| 6 | + |
| 7 | +# # float |
| 8 | +# i = 30.5 |
| 9 | +# print(i) |
| 10 | +# print(type(i)) |
| 11 | + |
| 12 | +# Complex (imaginery No.) |
| 13 | +# i = 30+5j |
| 14 | +# print(i) |
| 15 | +# print(type(i)) |
| 16 | + |
| 17 | +# num1 = float(input("Enter the num1 : ")) |
| 18 | +# num2 = float(input("Enter the num2 : ")) |
| 19 | + |
| 20 | +# result = (num1+num2) |
| 21 | +# print(result,"%") |
| 22 | +# print(type(result)) |
| 23 | + |
| 24 | +# boolean Data (True/False) |
| 25 | +# i = True |
| 26 | +# print(type(i)) |
| 27 | +# i = False |
| 28 | +# print(type(i)) |
| 29 | +# i = 0 #False it is 0 |
| 30 | +# j = 1 # true it is positive 1 |
| 31 | +# print(bool(j)) |
| 32 | + |
| 33 | +# Byte Data |
| 34 | +# i = "Mayank" # Character type data |
| 35 | +# print(type(i)) |
| 36 | + |
| 37 | +# i = b"Mayank" # Byte Type data ,ASCII Code provided in any letter symbole or number |
| 38 | +# print(type(i)) |
| 39 | + |
| 40 | +# print("",i) |
| 41 | + |
| 42 | +# None type # i don't know the defing the data |
| 43 | + |
| 44 | +# i = None |
| 45 | +# print(i) |
| 46 | + |
| 47 | +# Non primitive datatype ,Collection Type |
| 48 | + |
| 49 | +# l1 = [1,2,3,4,5] |
| 50 | +# print("List1",l1) |
| 51 | +# print("List1",type(l1)) |
| 52 | +# print(l1[4]) # List index out of range |
| 53 | + |
| 54 | +# # list is used a CRUD operation |
| 55 | +# l1[3] = "Python" ## Update value |
| 56 | +# print(l1) |
| 57 | +# l1.append(45) ## adding value |
| 58 | +# print(l1) |
| 59 | +# l1.remove("Python") ## Removing value |
| 60 | +# print(l1) |
| 61 | + |
| 62 | +# Tuple |
| 63 | + |
| 64 | +# t1 = (1,2,3,4,5) |
| 65 | +# print(t1) |
| 66 | +# print(type(t1)) |
| 67 | +# print(t1[2]) |
| 68 | + |
| 69 | +# tuple is Do not use a CRUD operation |
| 70 | +# t1[3] = "Python" ## Update value |
| 71 | +# print(t1) |
| 72 | +# t1.append(45) ## adding value |
| 73 | +# print(t1) |
| 74 | +# t1.remove("Python") ## Removing value |
| 75 | +# print(t1) |
| 76 | + |
| 77 | +# Set |
| 78 | +# s1 = {1,2.44,3+4j,False} ## Un arranged data not follow the sequencing |
| 79 | +# print(s1) |
| 80 | +# print(type(s1)) |
| 81 | +# print(s1[2]) # Don't access through the index value in set |
| 82 | + |
| 83 | +# set is Do not use a CRUD operation only use create ,read or Delete |
| 84 | +# s1.remove(2.44) ## Removing value |
| 85 | +# print(s1) |
| 86 | +# s1.add("Mayank") ## add value |
| 87 | +# print(s1) |
| 88 | + |
| 89 | +# Frozenset or set will be same |
| 90 | +# f1 = {1,2.44,3+4j,False} ## Un arranged data not follow the sequencing |
| 91 | +# print(frozenset(f1)) |
| 92 | +# print(type(f1)) |
| 93 | +# print(f1[2]) # Don't access through the index value in set |
| 94 | +# set is Do not use a CRUD operation only use create ,read or Delete |
| 95 | + |
| 96 | + |
| 97 | +# Range |
| 98 | + # Start #end #step |
| 99 | +# print(list(range(1,11,1)), "list") |
| 100 | +# print(tuple(range(1,11,1)), "tuple") |
| 101 | +# print(set(range(1,11,1)), "set") |
| 102 | +# print(frozenset(range(1,11,1)), "frozenset") |
| 103 | + |
| 104 | +# print(list(range(11))) |
| 105 | + |
| 106 | +# Reverse the counting |
| 107 | +# r = range(11,0,-1) |
| 108 | +# you can type cast the range data any formate like list tuple set |
| 109 | +# print(list(r)) |
| 110 | + |
| 111 | +# Don't change the data |
| 112 | +# print(r[6]) |
| 113 | + |
| 114 | + |
| 115 | +# # Dictionery ('Key' : 'Value') |
| 116 | + |
| 117 | +# dic = { |
| 118 | +# 'name' : "Mayank", |
| 119 | +# 'class' : "5th", |
| 120 | +# 'roll_no' : 2682483894, |
| 121 | +# 'school' : 'Summer Field Public School' |
| 122 | +# } |
| 123 | +# print(dic) |
| 124 | +# print(type(dic)) |
| 125 | + |
| 126 | +# data1 = { |
| 127 | +# 'a' : ['apple','airplane','alpha'],1:2.5,3:3+5j,4:False} |
| 128 | +# print(data1) |
| 129 | +# print(type(data1)) |
| 130 | + |
| 131 | +# ### you can use CRUD operation |
| 132 | + |
| 133 | +# data1[1]=300 ## Updating the data |
| 134 | +# print(data1) |
| 135 | + |
| 136 | +# data1['b']='Name' ## Adding the data |
| 137 | +# print(data1) |
| 138 | + |
| 139 | +# print(data1['a'][1]) ## you can access the data / reading |
| 140 | + |
| 141 | +# data1.pop(3) ## can we delete the key automatic data deleted |
| 142 | +# print(data1) |
| 143 | + |
| 144 | + |
| 145 | + |
| 146 | +# data1 = {'menu': ['Pizza','Maggi','Pasta','Chill Patato','Bargar']} |
| 147 | +# print(data1) |
| 148 | +# print(type(data1)) |
0 commit comments