In this we are going to see a basic program on checking float and integer in 3D array in Python Programming Language.
float_count = 0
int_count = 0
list = [[[3,4.0,2,8.4,6],[0,2,0.2,4,6],[9,3.5,0.32,5,4]],
[[6,1.0,8,3.4,8.1],[0,2,0.3,4,6.7],[4,3.5,0.32,5.6,4]],
[[3,4.0,2.2,8.34,6.9],[8,2,2,7,6.2],[8,3.1,32,5.2,8.7]]]
for l in list:
for item in l:
for subitem in item:
if isinstance(subitem, int):
int_count += 1
elif isinstance(subitem, float):
float_count += 1
print("Float count: {} \nInteger count: {}".format(float_count, int_count))
# Coded by Saahil
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP