Skip to content

Commit c915b4e

Browse files
committed
solution to 6, 7
1 parent 52efc63 commit c915b4e

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

programming_exercises.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ Level 1
116116
Question:
117117
Define a class which has at least two methods:
118118
getString: to get a string from console input
119-
printString: to print the string in upper case.
120119
Also please include simple test function to test the class methods.
121120

122121
Hints:
@@ -2352,6 +2351,7 @@ Question:
23522351
Write a program to solve a classic ancient Chinese puzzle:
23532352
We count 35 heads and 94 legs among the chickens and rabbits in a farm. How many rabbits and how many chickens do we have?
23542353

2354+
Hint:
23552355
Hint:
23562356
Use for loop to iterate all possible solutions.
23572357

@@ -2372,4 +2372,3 @@ print solutions
23722372

23732373
#----------------------------------------#
23742374

2375-

q1.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import math
2+
13
def printnumbers():
24
numbers = []
35
k=1
@@ -35,5 +37,36 @@ def splitthestr(s):
3537
print(slist)
3638
print(tuple(slist))
3739

38-
sa = input("give numbers")
39-
splitthestr(sa)
40+
#sa = input("give numbers")
41+
#splitthestr(sa)
42+
43+
class TestClass:
44+
45+
def __init__(self, name):
46+
self.name = name;
47+
48+
def getwelcomemessage(self):
49+
print('hello {}'.format(self.name))
50+
51+
#tc = TestClass("Jubayer")
52+
#tc.getwelcomemessage()
53+
54+
# problem 6
55+
56+
def calculateQ(D):
57+
C = 50
58+
H = 30
59+
Q = math.sqrt((2*C*D)/H)
60+
return math.floor(Q)
61+
def getnumbers(st):
62+
l = st.split(',')
63+
nl = [int(x) for x in l]
64+
return nl
65+
66+
#s = input("--> Numbers: ")
67+
#l = [calculateQ(x) for x in getnumbers(s)]
68+
#l = map(str, l)
69+
#print (','.join(l))
70+
71+
#problem 7
72+

0 commit comments

Comments
 (0)