1+ import math
2+ import numpy as np
13################# question 1 ###################
24def q1_div (x ,y ):
35 l = []
@@ -47,9 +49,51 @@ def printString(self):
4749#test5.printString()
4850
4951################# question 6 ###################
52+ def q6_sqr_func (c = 50 ,h = 30 ):
53+ value = []
54+ items = [x for x in input ().split (',' )]
55+ for d in items :
56+ value .append (str (int (round (math .sqrt (2 * c * float (d )/ h )))))
57+ print (',' .join (value ))
58+
59+ ################# question 7 ###################
60+ # defined using numpy, return numpy.ndarray
61+ def q7_array_build (x ,y ):
62+ a = np .zeros (shape = (x ,y ))
63+ for i in range (0 ,x ):
64+ for j in range (0 ,y ):
65+ a [i ][j ] = i * j
66+ print (a )
67+ return (a )
68+
69+ # defined using list of list, return list
70+ def q7_array_build_s ():
71+ input_str = input ()
72+ dimensions = [int (x ) for x in input_str .split (',' )]
73+ rowNum = dimensions [0 ]
74+ colNum = dimensions [1 ]
75+ multilist = [[0 for col in range (colNum )] for row in range (rowNum )]
76+
77+ for row in range (rowNum ):
78+ for col in range (colNum ):
79+ multilist [row ][col ]= row * col
80+ print (multilist )
81+ return (multilist )
82+
83+
84+ ################# question 8 ###################
85+ def q8_sort_words ():
86+ x_string = input ()
87+ x_list = [x for x in x_string .split (',' )]
88+ x_list .sort ()
89+ print (',' .join (x_list ))
90+
91+ ################# question 9 ###################
92+ def q9_capitilize_string ():
93+ x_string = input ()
94+ print (x_string .upper ())
95+
5096
5197
5298if __name__ == "__main__" :
53- test5 = q5_string ()
54- test5 .getString ()
55- test5 .printString ()
99+ q9_capitilize_string ()
0 commit comments