Jul-04-2021, 05:12 PM
(This post was last modified: Jul-04-2021, 08:49 PM by Yoriz.
Edit Reason: Added code tags
)
I have a question ( not homework, im basically studying to learn phyton a little before study ):
it says to write all the numbers between 2**1 to 2**7 in phyton.
In for i saw a solution, but i didnt really understand:
for while, I tried something but it didnt work.. ( picture below ). but basically I did this:
i tried doing the bbcode thingy, but i couldnt see where i write it, the post doesnt say where to use bbcode thingy.
it says to write all the numbers between 2**1 to 2**7 in phyton.
In for i saw a solution, but i didnt really understand:
for num in (1, 2, 3 , 4, 5 , 6 ,7): print(2**num)and that way i got in phyton 2, 4 ,8, 16 and such.. up to 128 ( can somone explain to me please this thing? never heard of a for like that, with the () and in together.
for while, I tried something but it didnt work.. ( picture below ). but basically I did this:
num = 2 while num**2 in range(1,7): print(2**num)I just kept getting 4,4,4,4,4,4 every time, cant make it to 128. any explanation please?
i tried doing the bbcode thingy, but i couldnt see where i write it, the post doesnt say where to use bbcode thingy.