Hello Python Masters,
I am an absolute beginner in Phyton, trying to teach myself, and first time member of this forum. Pardon me for asking for help with the example below as I am completely out of your league with regards to knowledge of python. Can someone please explain in simple terms line by line how the output are arrived at? I am doing self tutorial and I am stuck in this section and I dont want to proceed without understanding the logic behind the input lines because I'm sure I will come across this topic again later. Also if you can recommend an online site that provides tutorials for beginners. Thank you so much for your help.
#Input
I am an absolute beginner in Phyton, trying to teach myself, and first time member of this forum. Pardon me for asking for help with the example below as I am completely out of your league with regards to knowledge of python. Can someone please explain in simple terms line by line how the output are arrived at? I am doing self tutorial and I am stuck in this section and I dont want to proceed without understanding the logic behind the input lines because I'm sure I will come across this topic again later. Also if you can recommend an online site that provides tutorials for beginners. Thank you so much for your help.
#Input
for n in range(2, 10): ... for x in range(2, n): ... if n % x == 0: ... print n, 'equals', x, '*', n/x ... break ... else: print n, 'is a prime number'#Output
Output:2 is a prime number
3 is a prime number
4 equals 2 * 2
5 is a prime number
6 equals 2 * 3
7 is a prime number
8 equals 2 * 4
9 equals 3 * 3