-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFull Python Repository.py
More file actions
1088 lines (982 loc) · 22.1 KB
/
Copy pathFull Python Repository.py
File metadata and controls
1088 lines (982 loc) · 22.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# ::::::::::::::::::::::[ HELLO Code Knight ]::::::::::::::::::::::::::
# name = "CodeKinght"
# print("hello " + name)
# print(type(name))
# STRING
# first_name = "CodeKinght"
# last_name = "Lord"
# full_name = (first_name + " " + last_name)
# print(first_name)
# print(last_name)
# print(full_name)
# INTEGER
# age = 17
# age += 1
# print("your age is : " + str(age))
# print(float(age))
# print(str(age))
# print(type(age))
# FLOAT
# height = 250.5
# height += 20
# print("your height is : " + str(height) + " cm")
# print(int(height))
# print(type(height))
# BOOLEAN
# human = True
# print("Are you a human: " + str(human))
# print(type(human))
# START , STOP , STEP [x:y:z]
# 1. START
# name = "CodeKinght Knight"
# first_name = name[0:5]
# print(first_name)
# first_name = name[:5]
# print(first_name)
# 2. STOP
# last_name = name[:11]
# print(last_name)
# last_name = name[::]
# print(last_name)
# 3. STEP
# funky_name = name[::2]
# print(funky_name)
# funky_name = name[::3]
# print(funky_name)
# reversed_name = name[::-1]
# print(reversed_name)
# SLICE
# website1 = 'http://google.com'
# website2 = 'http://wikipedia.com'
# Slice = slice(7, -4)
# print(website1[Slice])
# print(website2[Slice])
# IF , ELIF , ELSE statements
# age = int(input("How old are you? :"))
# if age == 100:
# print('You are a century old!')
# elif age >= 18:
# print('you are an Adult!')
# elif age < 0:
# print('You haven`t been born yet!')
# else:
# print('You are a child!')
# AND , OR , NOT logics
# temp = int(input("What`s the temperature today? :"))
# if 0 < temp < 30:
# print("The temperature is good today!")
# print("Go outside!")
# elif temp < 0 or temp > 30:
# print("The temperature is bad today!")
# print("Stay inside!")
# if not (0 < temp < 30):
# print("The temperature is bad today!")
# print("Stay inside!")
# elif not (temp < 0 or temp > 30):
# print("The temperature is good today!")
# print("Go outside!")
# WHILE (LOOP)
# name = ""
# while len(name) == 0:
# name = input("Enter Your Name: ")
# print("Greetings : "+name)
# name = None
# while not name:
# name = input("Enter Your Name : ")
# print("Greetings : "+name)
# FOR LOOP
# for i in range(10):
# print(i+1)
# for i in range(10, 0+1, -2):
# print(i)
# for i in "CodeKinght Knight":
# print(i)
# import time
# for seconds in range(10, 0, -1):
# print(seconds)
# time.sleep(1)
# print("Happy New Year")
# NESTED LOOP
# rows = int(input("How many rows?: "))
# columns = int(input("How many columns?: "))
# Symbol = input("Enter a symbol to use: ")
# for i in range(rows):
# for j in range(columns):
# print(Symbol, end="")
# print()
# BREAK , CONTINUE , PASS
# 1.BREAK
# while True:
# name = input("Enter your name: ")
# if name != "":
# break
# 2.CONTINUE
# phone_number = "123-456-7890"
# for i in phone_number:
# if i == "-":
# continue
# print(i, end="")
# 3.BREAK
# for i in range(1, 21):
# if i == 13:
# pass
# else:
# print(i)
# LIST
# food = ["Pizza", "Spaghetti", "Pudding", "Masala Rice", "Burger", "Coke", "Sushi"]
# print(food)
# print(food[0])
# food[0] = "Cake"
# print(food[0])
# food.append("Ice Cream")
# food.remove("Sushi")
# food.pop()
# food.insert(-2, "Pepsi")
# food.sort()
# food.clear()
# for x in food:
# print(x)
# 2D LIST (LIST OF LIST)
# drinks = ["Tea", "Coffee", "Soda"]
# dinner = ["Pizza", "Burger", "Sushi"]
# desert = ["Cake", "Pudding", "Ice Cream", "Shira"]
# food = [drinks, dinner, desert]
# print(food[1][1])
# TUPLE
# student = ("CodeKinght", 17, "Male")
# print(student.count("CodeKinght"))
# print(student.index("Male"))
# for x in student:
# print(x)
# if "CodeKinght" in student:
# print("CodeKinght is here!")
# SETS
# utensils = {"fork", "spoon", "knife"}
# dishes = {"bowl", "plate", "cup", "knife"}
# utensils.add("napkin")
# utensils.remove("fork")
# utensils.update(dishes)
# print(utensils.difference(dishes))
# print(utensils.union(dishes))
# print(dishes.intersection(utensils))
# print(utensils.clear())
# print(utensils)
# DICTIONARY
# capitals = {"USA": "Washington DC",
# "China": "Beijing",
# "India": "Delhi",
# "Russia": "Moscow"}
# capitals.update({"Germany": "Berlin"})
# capitals.update({"USA": "Las Vegas"})
# print(capitals['Germany'])
# print(capitals.get("Japan"))
# print(capitals.keys())
# print(capitals.values())
# print(capitals.items())
# for keys, values in capitals.items():
# print(keys, values)
# INDEX OPERATOR ([])
# name = "CodeKinght Knight!"
#
# if name[0].islower():
# name = name.capitalize()
#
# print(name)
#
# first_name = name[:4].upper()
# last_name = name[5:-1].lower()
# last_character = name[-1]
#
# print(first_name)
# print(last_name)
# print(last_character)
# FUNCTIONS
#
# def hello(first_name, last_name, age):
# print("Hello "+first_name+" "+last_name)
# print("You are "+str(age)+" years old!")
# print("Have a nice day!")
#
#
# hello("CodeKinght", "Knight", 17)
# RETURN STATEMENT
# def multiply(number1, number2):
# return number1 * number2
#
#
# x = multiply(23, 3)
# print(x)
# KEYWORD ARGUMENTS
# def hello(first, middle, last):
# print("Hello "+first+" "+middle+" "+last)
#
#
# hello(last="Knight", middle="Dark", first="CodeKinght")
#
# NESTED FUNCTION CALL
#
# num = input("Enter a whole number: ")
# num = float(num)
# num = abs(num)
# num = round(num)
# print(num)
# OR
# print(round(abs(float(input("Enter a whole number: ")))))
# SCOPE 1)GLOBAL SCOPE- IT IS AVAILABLE INSIDE AND OUTSIDE ANY FUNCTION
# 2)LOCAL SCOPE- IT IS AVAILABLE ONLY INSIDE A FUNCTION
# name = "CodeKinght"
#
#
# def display_name():
# last_name = "Knight"
# print(last_name)
#
#
# print(name, end=" ")
# display_name()
# *ARGS
# operation = "Sum"
#
#
# def add(*args):
# sum = 0
# args = list(args)
# args[0] = 0
# for i in args:
# sum += i
# return sum
#
#
# print("The " + operation + " is", add(1, 2, 3, 4, 5, 6, 7))
# **KWARGS
# 1)
# def hello(**kwargs):
# print("Hello " + kwargs['first'] + kwargs['last'])
#
#
# hello(first="CodeKinght ", last="Knight")
# 2)
# def hello(**kwargs):
# print("Hello ", end=" ")
# for key, value in kwargs.items():
# print(value, end=" ")
#
#
# hello(title="Mr.", first="CodeKinght", middle="Dark", last="Knight")
# STR.FORMAT()
# 1]
# animal = "cow"
# item = "moon"
#
# print("The " + animal + " jumped over the " + item)
# print("The {} jumped over the {}".format(animal, item))
# print("The {1} jumped over the {0}".format(item, animal))
# print("The {animal} jumped over the {item}".format(animal="cow", item="moon"))
# text = "The {} jumped over the {}"
# print(text.format(animal, item))
# 2]
# name = "CodeKinght"
#
# print("Hello, my name is {}".format(name))
# print("Hello, my name is {:10}. Nice to meet you".format(name))
# print("Hello, my name is {:<10}. Nice to meet you".format(name))
# print("Hello, my name is {:>10}. Nice to meet you".format(name))
# print("Hello, my name is {:^10}. Nice to meet you".format(name))
# 3]
# pi = 3.14159
# number = 1000
#
# print("The number pi is {:.2f}".format(pi))
# print("the number is {:,}".format(number))
# print("the number is {:b}".format(number))
# print("the number is {:o}".format(number))
# print("the number is {:X}".format(number))
# print("the number is {:E}".format(number))
#
# RANDOM
# import random
#
# x = random.randint(1, 6)
# y = random.random()
# mylist = ["Rock", "Paper", "Scissors"]
# z = random.choice(mylist)
# cards = ["A", 2, 3, 4, 5, 6, 7, 8, 9, 10, "J", "Q", "K"]
# random.shuffle(cards)
# print(x)
# print(y)
# print(z)
# print(cards)
#
# EXCEPTIONS
# try:
# numerator = int(input("Enter a number to divide: "))
# denominator = int(input("Enter a number to divide by: "))
# result = numerator / denominator
# except CodeKinghtDivisionError as e:
# print(e)
# print("You cannon divide by CodeKinght! idiot! ")
# except ValueError as e:
# print(e)
# print("Enter a number plz")
# except Exception as e:
# print(e)
# print("Something went wrong")
# else:
# print(result)
# finally:
# print("This will always execute")
# FILE DETECTION
# import os
#
# path = "C:\\1NANUSH\\The Mid Future\\Guide"
#
# if os.path.exists(path):
# print("The location exists!")
# if os.path.isfile(path):
# print("This is a file")
# elif os.path.isdir(path):
# print("This is a directory")
# else:
# print("This location doesn't exist!")
#
# OPENING AND READING FILE
# try:
# with open("C:\\Users\\HP\\Desktop\\CodeKinght.txt") as file:
# print(file.read())
# except FileNotFoundError:
# print("This file was not found :(")
#
# WRITING AND EDITING A TXT FILE
# text1 = "With \"w\" you can overwrite a file"
# text2 = "\nWith \"a\" you can edit a txt file"
#
# with open("TestingFile.txt", 'w') as file:
# file.write(text1)
# with open("TestingFile.txt", 'a') as file:
# file.write(text2)
# COPY FILE
# import shutil
#
# shutil.copy("C:\\Users\\HP\\Desktop\\CodeKinght.txt",'TestingFile.txt')
#
# MOVING FILES
# import os
#
# source = 'TestingFile2'
# destination = "C:\\Users\\HP\\Desktop\\TestingFile2"
#
# try:
# if os.path.exists(destination):
# print(source + " already exists")
# else:
# os.replace(source, destination)
# print(source + " was moved")
# except FileNotFoundError:
# print(source + " was not found")
# DELETING FILES
# import os
# import shutil
#
# path = "TestingFile.txt"
#
# try:
# os.remove("TestingFile.txt")
# os.rmdir('HI')
# shutil.rmtree("OK")
#
# except FileNotFoundError:
# print("File was not found")
# except PermissionError:
# print("You are not authorised to delete this file")
# except OSError:
# print("This directory contains files")
# else:
# print(path + " was deleted")
# MODULES
# import Testing
# Testing.hello()
#
# import Testing as tst
# tst.bye()
#
# from Testing import hello, bye
# hello()
# bye()
#
# from Testing import *
# hello()
# bye()
# OOP's
# from Cars import Car
#
# car_1 = Car("Dodge", "Challenger", 2018, "Black")
# car_2 = Car("McLaren", "570GT", 2017, "Red")
# car_3 = Car("Rolls-Royce", "Phantom", 2016, "White")
#
# print(car_3.make)
# print(car_3.model)
# print(car_3.year)
# print(car_3.color)
#
# car_1.manual()
# car_3.auto()
# Car.wheels = 2
# print(Car.wheels)
# INHERITANCE
# class Animals:
#
# alive = True
#
# def eat(self):
# print("This animal is eating")
#
# def sleep(self):
# print("This animal is sleeping")
#
#
# class Rabbit(Animals):
#
# def run(self):
# print("This rabbit is running")
#
#
# class Fish(Animals):
#
# def swim(self):
# print("This fish is swimming")
#
#
# class Hawk(Animals):
#
# def fly(self):
# print("This hawk is flying")
#
#
# rabbit = Rabbit()
# fish = Fish()
# hawk = Hawk()
#
# rabbit.run()
# fish.swim()
# hawk.fly()
# print(rabbit.alive)
# fish.eat()
# hawk.sleep()
# MULTI-LEVEL INHERITANCE
# class Organism:
# alive = True
#
#
# class Animals(Organism):
#
# def eat(self):
# print("This animal is eating")
#
#
# class Dog(Animals):
#
# def bark(self):
# print("Tis dog is barking")
#
#
# dog = Dog()
# print(dog.alive)
# dog.eat()
# dog.bark()
# MULTIPLE INHERITANCE
# class Prey:
# def flee(self):
# print("This animal flees")
#
#
# class Preditor:
# def hunt(self):
# print("This animal hunts")
#
#
# class Rabbit(Prey):
# pass
#
#
# class Hawk(Preditor):
# pass
#
#
# class Fish(Prey, Preditor):
# pass
#
#
# rabbit = Rabbit()
# hawk = Hawk()
# fish = Fish()
#
# rabbit.flee()
# hawk.hunt()
# fish.flee()
# fish.hunt()
# METHOD OF OVER WRITING
# class Animals:
# def eat(self):
# print("This animal is eating")
#
#
# class Rabbit(Animals):
# def eat(self):
# print("This rabbit is eating a carrot")
#
#
# rabbit = Rabbit()
# rabbit.eat()
# METHOD CHAINING
# class Car:
# def turn_on(self):
# print("Turn on the engine")
# return self
#
# def drive(self):
# print("Drive the car")
# return self
#
# def stop(self):
# print("Step on the breaks")
# return self
#
# def turn_off(self):
# print("Turn off the engine")
# return self
#
#
# car = Car()
# car.turn_on()\
# .drive()\
# .stop().\
# turn_off()
# SUPER()
# class Rectangle:
# def __init__(self, length, width):
# self.length = length
# self.width = width
#
#
# class Square(Rectangle):
# def __init__(self, length, width):
# super().__init__(length, width)
#
# def area(self):
# return self.length*self.width
#
#
# class Cube(Rectangle):
# def __init__(self, length, width, height):
# super().__init__(length, width)
# self.height = height
#
# def volume(self):
# return self.length * self.width*self.height
#
#
# L = int(input("Length: "))
# W = int(input("Width: "))
# H = int(input("Height: "))
# square = Square(L, W)
# cube = Cube(L, W, H)
#
# print(f"The area of this rectangle is {square.area()} units")
# print(f"The volume of this cube is {cube.volume()} units")
# ABSTRACT METHODS
# from abc import ABC, abstractmethod
#
#
# class Vehicle(ABC):
# @abstractmethod
# def go(self):
# pass
#
# @abstractmethod
# def stop(self):
# pass
#
#
# class Car(Vehicle):
# def go(self):
# print("You drive the car")
#
# def stop(self):
# print("You stop the car")
#
#
# class Motorcycle(Vehicle):
# def go(self):
# print("You ride the motorcycle")
#
# def stop(self):
# print("You stop the motorcycle")
#
#
# car = Car()
# motorcycle = Motorcycle()
#
# car.go()
# motorcycle.go()
# car.stop()
# motorcycle.stop()
# PASSING OBJECTS AS ARGUMENTS
# class Car:
# colour = None
#
#
# class Motorcycle:
# colour = None
#
#
# def change_colour(vehicle, colour):
# vehicle.colour = colour
#
#
# car_1 = Car()
# car_2 = Car()
# car_3 = Car()
# bike_1 = Motorcycle()
#
# change_colour(car_1, "Red")
# change_colour(car_2, "White")
# change_colour(car_3, "Black")
# change_colour(bike_1, "Rose")
#
# print(car_1.colour)
# print(car_2.colour)
# print(car_3.colour)
# print(bike_1.colour)
# DUCK TYPING
# class Duck:
#
# def walk(self):
# print("This duck is walking")
#
# def talk(self):
# print("This duck is quacking")
#
#
# class Chicken:
# def walk(self):
# print("This Chicken is walking")
#
# def talk(self):
# print("This Chicken is quacking")
#
#
# class Person:
# def catch(self, duck):
# duck.walk()
# duck.talk()
# print("You caught the critter")
#
#
# duck = Duck()
# chicken = Chicken()
# person = Person()
#
# person.catch(duck)
# person.catch(chicken)
# WALRUS OPERATION
# happy = True
# print(happy)
# OR
# print(happy := True)
# foods = list()
# while True:
# food = input("What food do you like?: ")
# if food == "quit":
# break
# foods.append(food)
# OR
# foods = list()
# while food := input("What food do you like?: ") != "quit":
# foods.append(food)
# ASSIGNING FUNCTIONS AS VARIABLES
# def hello():
# print("Hello")
#
#
# hi = hello
# hello()
# hi()
#
# say = print
# say("Whoa! I can't believe this works :O")
# HIGHER ORDER FUNCTIONS
# def loud(text):
# return text.upper()
#
#
# def quiet(text):
# return text.lower()
#
#
# def hello(function):
# text = function("Hello")
# print(text)
#
#
# hello(loud)
# hello(quiet)
#
#
# def divisor(x):
# def dividend(y):
# return y/x
# return dividend
#
#
# divide = divisor(2)
# print(divide(10))
# LAMBDA FUNCTION
# def double(x):
# return x * 2
#
#
# print(double(5))
# double = lambda x: x * 2
# multiply = lambda x, y: x * y
# add = lambda x, y, z: x + y + z
# full_name = lambda first_name, last_name: first_name + " " + last_name
# age_check = lambda age: True if age >= 18 else False
# print(double(7))
# print(multiply(7, 3))
# print(add(7, 3, 4))
# print(full_name("CodeKinght", "Knight"))
# print(age_check(17))
# print(age_check(18))
# SORT()
# A] lists
# students = ["Squidward", "Sandy", "Patrick", "Spongebob", "Mr. Krabs"]
# students.sort()
#
# for i in students:
# print(i)
#
# students = [("Squidward", "F", 60),
# ("Sandy", "A", 33),
# ("Patrick", "D", 36),
# ("Spongebob", "B", 20),
# ("Mr. Krabs", "C", 78)]
# age = lambda ages: ages[2]
# students.sort(key=age, reverse=True)
#
# for i in students:
# print(i)
#
# B] Tuples
# students = ("Squidward", "Sandy", "Patrick", "Spongebob", "Mr. Krabs")
# sorted_students = sorted(students, reverse=True)
#
# for i in sorted_students:
# print(i)
# students = (("Squidward", "F", 60),
# ("Sandy", "A", 33),
# ("Patrick", "D", 36),
# ("Spongebob", "B", 20),
# ("Mr. Krabs", "C", 78))
# age = lambda ages: ages[2]
# sorted_students = sorted(students, key=age)
#
# for i in sorted_students:
# print(i)
# MAP(function, iterable)
# store = [("Shirt", 20.00),
# ("Pants", 25.00),
# ("Jackets", 50.00),
# ("Socks", 10.00)]
#
# to_euros = lambda data: (data[0], data[1]*0.82)
# store_euros = list(map(to_euros, store))
# for i in store_euros:
# print(i)
#
# FILTER(function, iterable)
# friends = [("Jack", 19),
# ("Rosa", 18),
# ("Eve", 17),
# ("Eden", 16),
# ("Wane", 21),
# ("Robert", 20)]
# age = lambda data: data[1] >= 18
# drinking_buddies = list(filter(age, friends))
#
# for i in drinking_buddies:
# print(i)
# REDUCE(function, iterable) FUNCTION
# import functools
#
# letters = ["H", "E", "L", "L", "O"]
# word = functools.reduce(lambda x, y: x + y, letters)
# print(word)
#
# numbers = [5, 4, 3, 2, 1]
# result = functools.reduce(lambda x, y: x*y, numbers)
# print(result)
# LIST COMPREHENSION
# students = [100, 90, 80, 70, 60, 50, 30, 0]
# passed_students = list(filter(lambda x: x >= 60, students))
# passed_students = [i for i in students if i >= 60]
# passed_students = [i if i >= 60 else "Failed" for i in students]
# print(passed_students)
# DICTIONARY COMPREHENSION
# 1. Dictionary = {key: expression for (key, value) in iterable}
# cities_in_F = {'New York': 32, 'Boston': 75, 'Los Angeles': 100, 'Chicago': 50}
# cities_in_C = {key: round((value-32)*(5/9)) for (key, value) in cities_in_F.items()}
# print(cities_in_C)
# 2. Dictionary = {key: expression for (key, value) in iterable if conditional}
# weather = {'New York': "Snowing", 'Boston': "Sunny", 'Los Angeles': "Sunny", 'Chicago': "cloudy"}
# sunny_weather = {key: value for (key, value) in weather.items() if value == "Sunny"}
# print(sunny_weather)
# 3. Dictionary = {key: (if/else) for (key, value) in iterable}
# cities_in_F = {'New York': 32, 'Boston': 75, 'Los Angeles': 100, 'Chicago': 50}
# desc_cities = {key: ("Warm" if value >= 40 else "Cold") for (key, value) in cities_in_F.items()}
# print(desc_cities)
# 4. Dictionary = {key: function(value) for (key, value) in iterable}
# def check_temp(value):
# if value >= 70:
# return "Hot"
# elif 69 >= value >= 40:
# return "Warm"
# else:
# return "Cold"
#
#
# cities = {'New York': 32, 'Boston': 75, 'Los Angeles': 100, 'Chicago': 50}
# desc_temp = {key: check_temp(value) for (key, value) in cities.items()}
# print(desc_temp)
# '__name__' == '__main__'
#
# def hello():
# print("Hello!")
#
#
# if __name__ == "__main__":
# hello()
# print("Running from Main!")
# else:
# hello()
# print("Running from Secondary!")
# Time
# import time
# print(time.ctime(0))
# print(time.time())
# print(time.ctime(time.time()))
# print(time.localtime())
# glb_t = time.gmtime()
# print(glb_t)
# print(time.strftime("%B %d %Y %H:%M:%S", glb_t))
#
# time_str = "25 October 2006"
# time_obj = time.strptime(time_str, "%d %B %Y")
# print(time_obj)
# time_tuple = (2020, 4, 20, 4, 20, 0, 0, 0, 0)
# time_str1 = time.asctime(time_tuple)
# time_str2 = time.mktime(time_tuple)
# print(time_str1)
# print(time_str2)
# import threading
# import time
#
#
# def eat_breakfast():
# time.sleep(3)
# print("You ate breakfast")
#
#
# def drank_coffee():
# time.sleep(4)
# print("You drank coffee")
#
#
# def study():
# time.sleep(5)
# print("You finished studying")