66print ('3 \t \t ' + str (3 * 3 ))
77print ('4 \t \t ' + str (4 * 4 ))
88
9+ # output:
10+ # Numbers Squares
11+ # 1 1
12+ # 2 4
13+ # 3 9
14+ # 4 16
915
1016# method 2:
1117def number_squares (start_num ,end_num ):
@@ -16,13 +22,28 @@ def number_squares(start_num,end_num):
1622 print (f"{ n } \t \t { n * n } " )
1723
1824try :
19- start_num ,end_num = map (int ,input ('Enter the starring and ending range with single space:' ).split (' ' ))
25+ start_num ,end_num = map (int ,input ('Enter the starting and ending range with single space:' ).split (' ' ))
2026 print ('Numbers\t \t Squares' )
2127 number_squares (start_num ,end_num )
2228except ValueError :
2329 print ("Invalid input! Please enter two integers separated by a space." )
2430
2531
32+ # output:
33+ # Enter the starting and ending range with single space:10 20
34+ # Numbers Squares
35+ # 10 100
36+ # 11 121
37+ # 12 144
38+ # 13 169
39+ # 14 196
40+ # 15 225
41+ # 16 256
42+ # 17 289
43+ # 18 324
44+ # 19 361
45+ # 20 400
46+
2647# Assignment 1:
2748# In Python to find the range of numbers that are both squares and cubes within a specified limit
2849def number_square_cubes (start_num ,end_num ):
@@ -33,13 +54,28 @@ def number_square_cubes(start_num,end_num):
3354 print (f"{ n } \t \t { n * n } \t \t { n * n * n } " )
3455
3556try :
36- start_num ,end_num = map (int ,input ('Enter the starring and ending range with single space:' ).split (' ' ))
57+ start_num ,end_num = map (int ,input ('Enter the starting and ending range with single space:' ).split (' ' ))
3758 print ('Numbers\t \t Squares\t \t Cubes' )
3859 number_square_cubes (start_num ,end_num )
3960except ValueError :
4061 print ("Invalid input! Please enter two integers separated by a space." )
4162
4263
64+ # output:
65+ # Enter the starring and ending range with single space:5 15
66+ # Numbers Squares Cubes
67+ # 5 25 125
68+ # 6 36 216
69+ # 7 49 343
70+ # 8 64 512
71+ # 9 81 729
72+ # 10 100 1000
73+ # 11 121 1331
74+ # 12 144 1728
75+ # 13 169 2197
76+ # 14 196 2744
77+ # 15 225 3375
78+
4379# Time Complexity
4480
4581# The main time complexity comes from the loop, which iterates over the numbers in the range [start_num, end_num].
0 commit comments