Lets read the following code carefully for a variety of inputs

// First program to read
x=raw_input("Enter a number:") # Remember this returns a string
x=int(x) # Turn the string x into an integer x.
if x>0:
 print 'Zero ',
 if x>10:
 print 'Ten ',
 if x > 20:
 print 'Twenty ',
print 'done'

//next problem
income=raw_input('What is your annual income?')
years=raw_input('How many years have you worked at your current job?'
years = int(years)
if income>=min_income or years > min_years:
 print 'You qualify for a loan.'
 print 'You must earn at least',min_income
 print 'or have been employed'
 print 'for more than',min_years,'years'
 print 'to qualify for a loan.'

//Third problem
// select different values of x, y and z and then determine what prints by inspection
// only. You can check later by running the program. Try to find different
// values of x,y and z that ends up running every instruction below.
x=raw_input('Enter the value (int) for x:')
x = int(x)
y=raw_input('Enter the value (int) for y:')
y = int(y)
z=raw_input('Enter the value (int) for z:')
z = int(z)
if x>y:
    print 'x is larger than y'
    m = x+m
    m = 2*m
    print 'x is less than or equal to y'
    m = y + m
    m = 3*m
    print 'm is',m
if x>0:
    if y>0:
        print 'Both positive'
        print 'x is positive'
    if y>0:
        print 'y is positive'
        print 'both negitive'
    print 'hmmmmm'
print 'done'

Comments are closed.