1.

New Question!!! Without using any Conditional contruct and Strings , print the following series:-0,5,0,5...Nth term#ShortestProgramPossible​

Answer»

d Answer:-Question:WITHOUT using CONDITIONAL construct and strings, print the following series upto nth term. 0 5 0 5...Solution:Here comes the PROGRAM. This might be the shortest program possible. n,a,b=int(INPUT("Enter limit - ")),0,5for i in range(n): print(a&5,end=" ") a,b=b,aIf you don't know about bitwise 'and', then you can use this approach. n=int(input("Enter the range - "))a,b=0,5for i in range(n): print(a,end=" ") a+=b b*=-1Algorithm:ACCEPT the limit. Initialise a=0 and b=5Display the value of a. Add value of b to a. Negate the value of b. Continue this steps n times.Refer to the attachment for output ☑



Discussion

No Comment Found