Created
September 15, 2022 12:39
-
-
Save saaeiddev/b88cdd3bcfb67f6fb6c1ca0c3ffc2a04 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
My_List = [10, 14, True, False, 2.4, "ali"] | |
for item in My_List: | |
if type(item) == int and item > 10: # for --> loop | |
print("there is a integer data type and it is bigger than 10") | |
print(item) | |
for item in My_List: | |
if type(item) == float and item > 2: | |
print(item) | |
print(item * 2) | |
if True in My_List: | |
print("yes") | |
else: | |
print("no") | |
def Sarti(x, y): | |
return x ** y | |
d = Sarti(3, 3) | |
print(d) | |
My_Dict1 = { | |
"name":"ali", "age":"23", "weight":"80", "height":"177" | |
} | |
My_List2 = [My_Dict1, 11, True, "yes", 3.3] | |
for member in My_List2: | |
if True in My_List2 and type(True) == bool: | |
print("yes, this is a boolean data type") | |
else: | |
print("no") | |
if My_Dict1 in My_List2: | |
print(My_Dict1.keys()) | |
print(My_Dict1.values()) | |
else: | |
for member in My_List2: | |
print(member, "checked") | |
for member in My_List2: | |
if type(member) == float and member > 3.2: | |
print("yes") | |
else: | |
for member in My_List2: | |
print(member) | |
print(type(member)) | |
# -------------------------------------------------------------------------- | |
class Plane(): | |
def __init__(self, model, color, engine): | |
self.model = model | |
self.color = color | |
self.engine = engine | |
p1 = Plane("f14", "black", 30000) | |
print(p1) | |
#-------------------------------------------------------------------------------- | |
class Laptop(): | |
def __init__(self, brand, model, color, cpu, ram): | |
self.brand = brand | |
self.model = model | |
self.color = color | |
self.cpu = cpu | |
self.ram = ram | |
l1 = Laptop("apple", "macbookpro_m1_2021", "gray", "M1", "16") | |
print(l1) | |
#----------------------------------------------------------------------------------- | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.