Q. Write programs using nested loops to produce the following pattern:
(i)
A
A B
A B C
A B C D
A B C D E
A B C D E F
(ii)
0
22
444
8888
You can understand by Watching video :-
Answer :-
(i).
for i in range(6): for j in range(6): if i >= j : print(chr(65+j)+" ",end="") print()
(ii).
for i in range(4): if i == 0 : print(0) continue for j in range(i+1): print(str(2**i),end="") print()
Alternate program :-
for i in range(4): if i == 0 : print(0) else: print(str(2**i)*(i+1) )
Bro second one is not loop. Loop is when you put a loop in another loop like for or while but you have used if else which is conditional
ReplyDeletePlease check it again.
DeleteYeah even question ask for nested loop
ReplyDeleteok.
Deletethe second one is not correct. bruh pls correct it and also there are four questions but u have solutions to only two of them also the second one is wrong. pls give the solutions to the other two ones and check the second one
ReplyDeleteSecond is coreect please check it again and tell me other two questions.
DeleteMaja ni aia
ReplyDeleteWhy you want Maja in Computer science 😁😁??
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )