Welcome, Guest: Join Nairaland / LOGIN! / Trending / Recent / NewStats: 2,624,176 members, 6,118,025 topics. Date: Monday, 25 January 2021 at 02:53 PM

## Learning Programming. (my Nairaland Journal) - Programming (4) - Nairaland

 Re: Learning Programming. (my Nairaland Journal) by syluck(m): 8:25pm On Nov 28, 2020 Karleb:Let say x has an initial value of 2. When you do x += 2 it a short hand for x = x + 2, which will give you 4. That means x = x + 2 'and' x += 2 are thesame thing. You can substitute the addition sign for any other arithmetic sign in python. x = 4 x *= 4 #16 x //= 2 #8 x -= 3 #5 x %= 2 #1 x /= 1 #1.0Concised and informative...I appreciate your help Re: Learning Programming. (my Nairaland Journal) by syluck(m): 8:25pm On Nov 28, 2020 naijasensei:Q1 - First understand what range() does. range(start, stop, step). The range function produces values from the start value, upto but NOT INCLUDING the stop value. That is;for i in range(1,10) supplies i with values 1,2,3,4,5,6,7,8,9. Assuming prompt = 10, and I want a range of values from 1 to 10 (10 inclusive), instead of range(1, prompt) I would rather use range(1, prompt + 1)Q2 - factorial = factorial * i is a programming concept you will see a lot of. It means multiply the value referenced by "i" with the current value referenced by "factorial", then let the new value referenced by factorial be (factorial * i)Q3 - s += i is the same as s = s + i, same explanation as in Q2s *= i is the same as s = s * i,s -= i is the same as s = s - i,and so on.Thanks bro... 1 Like Re: Learning Programming. (my Nairaland Journal) by syluck(m): 9:57am On Dec 17, 2020 Ok guys, I'm stuck in the while loop.Want it to print exactly what the for loop does Re: Learning Programming. (my Nairaland Journal) by Semtu(m): 1:14pm On Dec 17, 2020 syluck:Ok guys, I'm stuck in the while loop.Want it to print exactly what the for loop doesYour print statement is not under the while loop. Re: Learning Programming. (my Nairaland Journal) by syluck(m): 1:39pm On Dec 17, 2020 Semtu:Your print statement is not under the while loop.Still wouldn't give me what the for loop would gimme Re: Learning Programming. (my Nairaland Journal) by realman42: 2:46pm On Dec 17, 2020 Well-doneStart a project immediatelyU will learn fasterBrowse beginners projects Re: Learning Programming. (my Nairaland Journal) by Semtu(m): 4:20pm On Dec 17, 2020 syluck:Still wouldn't give me what the for loop would gimmeTwo things are wrong:1. You have to print str for each iteration as you've done for the for loop, which is print(str[i])2. The print statement should come before i+=1 2 Likes Re: Learning Programming. (my Nairaland Journal) by KingAbdulazeez: 4:33pm On Dec 17, 2020 Semtu:Two things are wrong:1. You have to print str for each iteration as you've done for the for loop, which is print(str[i])2. The print statement should come before i+=1This is giving annoying while loop Re: Learning Programming. (my Nairaland Journal) by syluck(m): 4:42pm On Dec 17, 2020 KingAbdulazeez:This is giving annoying while loopLol, u don't like using while loop? Re: Learning Programming. (my Nairaland Journal) by syluck(m): 4:45pm On Dec 17, 2020 Semtu:Two things are wrong:1. You have to print str for each iteration as you've done for the for loop, which is print(str[i])2. The print statement should come before i+=1Thanks. It worked Re: Learning Programming. (my Nairaland Journal) by Semtu(m): 4:46pm On Dec 17, 2020 KingAbdulazeez:This is giving annoying while loopI don't get Re: Learning Programming. (my Nairaland Journal) by KingAbdulazeez: 5:12pm On Dec 17, 2020 Semtu: I don't get the loop continues and didn't stop until I interrupted it. Re: Learning Programming. (my Nairaland Journal) by Semtu(m): 5:16pm On Dec 17, 2020 KingAbdulazeez: the loop continues and didn't stop until I interrupted it.To avoid an infinite loop, you must always increment i (i+=1) till the condition which is (i

(Go Up)

 Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Nairaland - Copyright © 2005 - 2021 Oluwaseun Osewa. All rights reserved. See How To Advertise. 139Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.