velocity--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[1], line 1 ----> 1 velocity NameError: name 'velocity' is not defined
Sep-Dec 2025 batch, Vikrant Patil
Date: 11 Oct 2025
© Vikrant Patil
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[1], line 1 ----> 1 velocity NameError: name 'velocity' is not defined
def velocity(u, a, t): # after colon..next line is always indented by 4 spaces
"""computes final velocity using newton's laws of motion
u = initial velocity m/s
a = acceleration m/s^2
t = time in seconds"""
final_velocity = u + a*t
return final_velocity
print("hello") # this print statement is not part of function hello
Help on function velocity in module __main__:
velocity(u, a, t)
computes final velocity using newton's laws of motion
u = initial velocity m/s
a = acceleration m/s^2
t = time in seconds
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[36], line 1 ----> 1 say_hello("vikrant") Cell In[35], line 2, in say_hello(name) 1 def say_hello(name): ----> 2 print("Hello", name.capitlize(), "!") AttributeError: 'str' object has no attribute 'capitlize'
Cell In[45], line 1 def add(2, 3): # this is not correct ^ SyntaxError: invalid syntax
Cell In[47], line 1 def cube("x"): # the argument here is not a name, it is literal text "x" ^ SyntaxError: invalid syntax
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[57], line 1 ----> 1 cube(5, 6) TypeError: cube() takes 1 positional argument but 2 were given
tuple is exactly same as list execpt that it is immutable
dictionary
[{'name': 'siddharth', 'profession': 'naturalist'},
{'name': 'Pallavi', 'profession': 'chemist'},
{'name': 'Anil', 'profession': 'Software'}]
len and find out how many students are there in classroom?len--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[85], line 1 ----> 1 nums NameError: name 'nums' is not defined
[{'name': 'siddharth', 'profession': 'naturalist'},
{'name': 'Pallavi', 'profession': 'chemist'},
{'name': 'Anil', 'profession': 'Software'}]
problem - consider data from your field which you use everyday. Try to fit that data into some nice structure using combination of lists and dictionaries
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[101], line 1 ----> 1 len(45) TypeError: object of type 'int' has no len()
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[104], line 1 ----> 1 int("4 5") ValueError: invalid literal for int() with base 10: '4 5'
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[105], line 1 ----> 1 int("45 years") ValueError: invalid literal for int() with base 10: '45 years'
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[112], line 1 ----> 1 nums NameError: name 'nums' is not defined
problem
Write a function max2 to find maximum from given two numbers. Then make use max2 to find maximum from three numbers and write another function max3