-
Notifications
You must be signed in to change notification settings - Fork 0
/
randomLearningTests.py
79 lines (67 loc) · 1.49 KB
/
randomLearningTests.py
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
# # for loop
# name = "David"
# for l in name:
# print(l)
# # while loop
# i = 1
# while i < 6:
# print(i)
# i += 1
# print("You have reached the end of the list")
# # list
# members = ["David", "John", "Ann", "Peter", "Jane"]
# for x in members:
# print(x)
# # break
# people = ["David", "John", "Ann", "Peter", "Jane"]
# for x in people:
# print(x)
# if x == "Peter":
# break
# print("You have reached the end of the list")
# # continue
# word_list = ["David", "John", "Ann", "Peter", "Jane"]
# for name in word_list:
# if name == "Peter":
# continue
# print(name)
# print("You have reached the end of the list")
# # countdown
# number = int(input())
# while number >= 0:
# print(number)
# number -= 1
# def fib(x):
# if x == 0 or x == 1:
# return 1
# else:
# return fib(x-1) + fib(x-2)
# print(fib(4))
# nums = {1, 2, 3, 4, 5, 6}
# nums = {0, 1, 2, 3} & nums
# nums = filter(lambda x: x > 1, nums)
# print(len(list(nums)))
# def power(x, y):
# if y == 0:
# return 1
# else:
# return x * power(x, y-1)
# print(power(2, 3))
# try:
# num1 = 7
# num2 = 0
# print(num1 / num2)
# print("Done calculation")
# except ZeroDivisionError:
# print("An error occurred")
# print("due to zero division")
# try:
# variable = 10
# print (10 / 2)
# except ZeroDivisionError:
# print("Error")
# print("Finished")
# file = open("filename.txt", "r")
# for i in range(21):
# print(file.read(4))
# file.close()