#python program (while and for loops)

11 messages · Page 1 of 1 (latest)

quaint vector
#

i currently have 2 programs that i need to write and i need some help with understanding some stuff, for the 1st one i created a pseudo-code: ask user for int n/ (get all odd ints from 1 to n/ get the square of all odd int from 1 to n/print all the odd squares)

vital frostBOT
#
  1. Ask your question and show the work you've done so far. If you've posted a screenshot of a question, specify which part you need help with.
  2. Wait patiently for a helper to come along.
  3. Once someone helps you, say thank you and close the thread with:
    +close
    
  4. Feel free to nominate the person for helper of the week in #helper-nominations
  5. Do not ping the mods, unless someone is breaking the rules. If there is a conflict amongst multiple helpers feel free to ping “Helper Mod”
  6. If you're happy with the help you got here, and the server overall, you can contribute financially as well:
quaint vector
#

the paranthesis in the pseudo-code indicate the things that will be done inside of the loop

#

ik how to get all the numbers between 1 and n but idk how to get only the odd numbers (and how to save them/use them since it's a loop)

quaint vector
#

update: i figured it out, i just need help printing it all on a single line

#

x=int(input())
y=1
if x>y:
while x>y:
print(y**2)
y=y+2

#

here's the code btw

#

1
9
25
49
81

#

here's the output for an input of x=10

#

+close