Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. #Program: convert_text_toNumber.py
  2. ## Created by Carson Young for CPSC 215
  3. # January 12, 2015
  4.  
  5. #Input: from the keyboard, symbols valid for a number (0...9, +, -0
  6. #process: Convert the characters input to a number using eval()
  7. #           add one to the number
  8. #Output:    The original string
  9. #           The string converted to a number
  10. #           The result of adding 1 to the number
  11.  
  12. def main():
  13.     print("This program inputs characters valid for a number, the converts")
  14.     print("the string to a number. It adds one to the number and prints it.")
  15.  
  16.     print()
  17.     number = input("Input a set of characters valid for a number: ")
  18.                     #convert the string that was input to a number
  19.  
  20.     number = eval(number)
  21.  
  22.     print(number)
  23.     print()
  24.     print("Now we will take your value and add 1 to it.")
  25.     number = number + 1
  26.     print(number)
  27.  
  28. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement