Skip to content

Instantly share code, notes, and snippets.

View vihar's full-sized avatar
🚀

Vihar Kurama vihar

🚀
View GitHub Profile
# var_name = value
myname = "Stark"
pi = 3.14
fuel = True
speed = 167
miles = 153.5
location = 16.789 + 12323.45j
car = "Mustang"
# type() function returns the datatype of variable.
print(fuel, type(fuel))
print(speed, type(speed))
world_tour = ["Paris", "New York", "Melbourne", "Swiss"]
print(type(world_tour))
print(world_tour)
print(world_tour[0])
print(world_tour[1])
print(world_tour[-1])
stationery_list = ["Pen", "Pencil", "Notepad"]
stationery_list.append("Eraser")
# Adds new item at the end of the list
print(stationery_list)
stationery_list.insert(2, "Files")
"""
Insert method inserts a single element into a list.It takes two arguments one is 
the numerical index at which the data is to be inserted and the other is value.
"""
atmosphere = ("Oxygen", "Hydrogen", "Nitrogen")
print(type(atmosphere))
print(atmosphere)
code_name = {"jack": 4098, "sape": 4139, "robb": 2323}
print(type(code_name))
print(code_name)
# You can remove items in the dictionary by using the del keyword.
del code_name["sape"]
print(code_name)
"""
You can update the values of the dictionaries by overriding them.
code_name[‘jack’] = 1212
"""
temperature = 27
if temperature <= 30:
print("Let’s go to the party!")
movie_tickets = 4
if(movie_tickets >= 4):
print("Tickets are available, Let’s go to the movie.")
else:
print("Let’s have a drink, tickets are not available.")
weight = 77
height = 180
bmi = (weight / (height**2)) * 10000
print("Computing…")
print("Your bmi is {}\n".format(bmi))
if bmi < 18.5:
print("Underweight")
elif 18.5 <= bmi <= 24.99:
print("Perfect ! Normal weight")
elif 25.00 <= bmi <= 30.00:
colors = ['Red', 'Black', 'Blue', 'White', 'Pink']
for color in colors:
print(color)