id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

alternate_add


Write a function to alternately add and subtract integer values from 1 to n. For example, alternate_add(5) = 1 - 2 + 3 - 4 + 5 = 3


alternate_add(3) → 2
alternate_add(5) → 3
alternate_add(8) → -4

...Save, Compile, Run (ctrl-enter)

def alternate_add(n):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Post-solution available

Copyright Nick Parlante 2017 - privacy