Difference makes the DIFFERENCE
def input_single_float(prompt):
user_input = input(prompt)
output = float(user_input)
return output
input_single_float('Enter the value of PI')
def input_single_float_01(prompt):
user_input = input(prompt)
try:
output = float(user_input)
except ValueError:
print("Input value is not as expected - enter numeric value")
output = None
except UnboundLocalError:
output = None
return output
input_single_float_01("Enter any number")
course = "Foundations of Data Science"
words = course.split()
print(words)
# content within a square bracket is a list type
words[1]
words[0]
words[1:3]
words[2:5]
words[3:34]
print(type(words))
print(words[0])
print(words[-1])
print(words[-2])
fibo_list = [1,1,2,3,5,8,13,21,34]
print(type(fibo_list))
print(fibo_list[2])
print(fibo_list[2] + 10)
print(fibo_list[2:4])
print(type(fibo_list[3:6]))
print(fibo_list[3:6])
for i in fibo_list:
print(i)
print(len(fibo_list))
length = len(fibo_list)
for i in range(length):
print(i)
for i in range(length):
print(i + 1.52)
bm_record = ['Abel', 12, 23.34, False]
print(type(bm_record))
print(bm_record[2])
print(bm_record[1])
print(bm_record[1:3])
bm_record.append('abel@idontknow.com')
bm_record
print(bm_record)
for i in bm_record:
print(i, type(i))
bm_record[0] = "Abel Ashwin"
for i in bm_record:
print(i)
bm_record.count("Abel Ashwin")
bm_record.extend?
cm_record = ['Sameer', 25.254, 12.23]
bm_record.append(cm_record)
bm_record
print(bm_record)
bm_record.extend(cm_record)
print(bm_record)
bm_record = ['Abel', 12, 23.34, False]
print(bm_record.reverse())
print(bm_record)
print(fibo_list.reverse())
fibo_list.reverse()
print(fibo_list)
fibo_list.sort()
print(fibo_list.sort())
fibo_list.remove?
# Remove first occurrence of value.
#Raises ValueError if the value is not present.
fibo_list.pop?
# Remove and return item at index (default last).
# Raises IndexError if list is empty or index is out of range.
bm_record = [
['Abel', 75, 1.73, False],
['Ashwin', 120, 1.78, True]
]
print(type(bm_record))
bm_record
bm_record[0]
bm_record[1]
bm_record[0][1]
bm_record[1][2]
bm_record[0][0] = "Abel brother of Cain"
bm_record[0]
bm_record[0].append("abel@idontknow.com")
bm_record[0]
bm_record
bm_record[1][1] = 125
bm_record
identity_3 = [
[1,0,0],
[0,1,0],
[0,0,1]
]
identity_3[1][2]
identity_3[1][1]
identity_3[1, 0]
A = [1, 2]
B = A
A[0] = A[0] + A[1]
print(A)
print(B)
A = [1, 2]
B = [item for item in A]
print(B)
A[0] = A[0] + A[1]
print(A)
print(B)
A = [
[1, 1],
[1, 0]
]
!pip install nbconvert
%shell jupyter nbconvert --to html /content/testfile.ipynb
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END CELL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~