Example use sentences for and while (bucles)

#USE FOR #EXAMPLE 1 PRINT SUMMING OF N NUMBERS N=input("How many numbers to summing?") acu=0 #FOR VARIABLE IN RANGE(initiation,intervale,end) for i in range(N): x=("input number") acu=acu+x print("the summing is ",acu) #USE WHILE #EXAMPLE 2 #WHILE(CONDITION) n=("input number") while(n!=-1): if(n%2==0)_ print("is pair") elif(n%2!=0): print("is odd") else: print("not is number") n=("input number") #EXAMPLE 3 while(True): n=input("input number") if(n==-2) break else: if(n%2==0)_ print("is pair") elif(n%2!=0): print("is odd") else: print("not is number") n=("input number")

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.