-
Notifications
You must be signed in to change notification settings - Fork 0
/
day8.py
126 lines (90 loc) · 2.43 KB
/
day8.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
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
'''
Day 1
_list = []
for i in range(2000, 3201):
if i % 7 === 0 and i % 5 != 0:
_list.append(str(i))
print(','.join(_list))
Day 2
def factorial(num):
if num < 0:
return "Must be greater than 0"
if num == 0:
return 1
return num * factorial(num-1)
Day 3
print("Enter a number: ")
n = int(input())
d = dict()
for i in range(1, n+1):
d[i] = i *i
print(d)
Day 4
values = input("Enter comma seperated values: ")
list = values.split(',')
tuple = tuple(list)
print(list, tuple)
Day 5
Class Mom(object):
def __init__(self):
self.n = ''
def getName(self):
self.n = str(input("Enter name for Mom: "))
def printMomsName(self):
print(self.n.upper())
Day 6
import math
c = 50
h = 30
x = []
y = [i for input("Enter a number or numbers: ").split(',')]
for d in y:
x.append(str(int(round(math.sqrt(2*c*float(d)/h)))))
print(','.join(x))
Day 7
input_for_system = input("Enter input: ")
dimension = [int(x) for x in input_for_system.split(',')]
rowin = dimension[0]
colin = dimension[1]
list = [[0 for column in range(colin)] for rows in range(rowin)]
for row in range(rowin):
for col in range(colin):
list[row][col] = row*col
print(list)
'''
#Day 8
# to get each item in list printed I could...
pets = ['dog', 'cat', 'bird', 'rabbit', 'fish', 'neighbor']
print(pets[0])
print(pets[1])
print(pets[2])
print(pets[3])
print(pets[4])
print(pets[5], '/n')
#or use a for loop to print everything in pets
for doodeledy in pets:
print(doodeledy)
#rock out a conditional statement with a while loop
i_got_20_bucks = 20
while i_got_20_bucks < 35:
print(i_got_20_bucks)
i_got_20_bucks += 1
print("I need more money")
# for all numbers between 1500 and 2700, which are divisible by 7 and a multiple of 5
for i in range(1500, 2701):
if i % 7 == 0 and i % 5 == 0:
print(i)
#write a program that will guess a number between 1 and 10
import random
target_num, guess_num = random.randint(1,10), 0
while target_num != guess_num:
guess_num = int(input('Guess a number between 1 and 10, and keep guessing till correct'))
print('game over')
#create a cool printed pattern that looks like a sideways triangle
count = 0
for num in range(7):
count += 1
print('*' * count)
for num in range(6):
count -= 1
print('*' * count)