Skip to content

Instantly share code, notes, and snippets.

@guillermohernandez
Created January 20, 2016 00:29
Show Gist options
  • Save guillermohernandez/529bd482cb948de9e28a to your computer and use it in GitHub Desktop.
Save guillermohernandez/529bd482cb948de9e28a to your computer and use it in GitHub Desktop.
ACA python
first_num = raw_input("Please input first number: ")
#line 1 asks for input, much like prompt() in javascript and saves it to a variable first_num
sec_num = raw_input("Please input second number: ")
#same as above but saves it in the sec_num variable
answer = int(first_num) + int(sec_num)
#so int is like javascript's parseInt() and turns the input into a whole number.
#first_num and sec_num get saved in the answer variable
print "Now I will add your two numbers: ", answer
#print is like document.write in JS so it shows the line "Now I will..." and then the value of answer variable
print "Pretty cool, huh?"
#shows the line above
print "Now I'll count backwards from ", answer
#shows "Now I'll count..." and the value of the answer variable
counter = answer
#the answer variable is stored in a new variable named counter
while (counter >= 0):
print counter
counter = counter - 1
#A while loop: While the value of counter is greater than or equal to zero, show the value of counter,
#then subtract 1 from the value of counter and repeat until the value of counter is greater than or equal to 0.
#This will run until the value of counter is -1
#can be written as counter--
print "All done!"
#"All done!" is displayed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment