import sys
! hostname
! whoami
print(sys.executable)
print(sys.version)
print(sys.version_info)
for
loop¶# sum numbers from 1 to n
howmany = int(input('Enter N'))
accumulator = 0.0
for i in range(1,howmany+1,1):
accumulator = accumulator + float(i)
print( 'Sum from 1 to ',howmany, 'is %.3f' % accumulator )
# sum even numbers from 1 to n
howmany = int(input('Enter N'))
accumulator = 0.0
for i in range(1,howmany+1,1):
if i%2 == 0:
accumulator = accumulator + float(i)
print( 'Sum of Evens from 1 to ',howmany, 'is %.3f' % accumulator )
howmany = int(input('Enter N'))
linetoprint=''
for i in range(1,howmany+1,1):
linetoprint=linetoprint + '*'
print(linetoprint)
while
loop¶# sum numbers from 1 to n
howmany = int(input('Enter N'))
accumulator = 0.0
counter = 1
while counter <= howmany:
accumulator = accumulator + float(counter)
counter += 1
print( 'Sum from 1 to ',howmany, 'is %.3f' % accumulator )
# sum even numbers from 1 to n
howmany = int(input('Enter N'))
accumulator = 0.0
counter = 1
while counter <= howmany:
if counter%2 == 0:
accumulator = accumulator + float(counter)
counter += 1
print( 'Sum of Evens 1 to ',howmany, 'is %.3f' % accumulator )
howmany = int(input('Enter N'))
linetoprint=''
counter = 1
while counter <= howmany:
linetoprint=linetoprint + '*'
counter += 1
print(linetoprint)