Web Analytics Made Easy -
StatCounter Python question - CodingForum

Announcement

Collapse
No announcement yet.

Python question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Python question

    Hello, I'm completely new towards Python. My question is:

    How to assign an unknown variable that is larger than the previous unknown variable? E.g:

    a = int(input())
    b = ???? (an unknown number/integer that must be larger than a)

    print(b - a)

    Sample Input:

    3 14

    Sample Output


    11

  • #2
    you don't use var int float identifiers in python, it is a smart enough language to figure out the data type "string" float 2.0 int1
    Code:
    def sample_script(a,b):
        a,b = 3,14
        return b-a
    python 2x raw_input python 3x input

    Comment


    • #3
      oh also I see what you are doing try:
      Code:
      a = input('ask for number or whatever)
      b = input('the same)
      print (int(b) - int(a)) #the conversion I think this is what you were asking done after input

      Comment


      • #4
        sorry one last thing I noticed I missed the first time i GOT KIDS RUNNING RAMPID

        [code]
        a = input('number:'):
        try:
        b = input(' ask for them to make the number larger here')
        print (int(b) - int(a)
        except: # you can add exeption type if you wish but re ask
        b = input(' I SAID LARGER FOOL')

        Comment

        Working...
        X