This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# var_name = value | |
myname = "Stark" | |
pi = 3.14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
atmosphere = ("Oxygen", "Hydrogen", "Nitrogen") | |
print(type(atmosphere)) | |
print(atmosphere) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
temperature = 27 | |
if temperature <= 30: | |
print("Let’s go to the party!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
colors = ['Red', 'Black', 'Blue', 'White', 'Pink'] | |
for color in colors: | |
print(color) |
OlderNewer