mardi 18 septembre 2018

Different Result/Output between Using Variable and 'OR' or without using Variable and 'OR' in the IF in PYTHON

I need help. I'm super newbie on python, I'm curious what's the technical good answer About the difference output result from the 2 samples above(just OR without variable(GPA) and OR with variable(GPA))?

#First sample simple code
    GPA= input('Enter GPA Grade: ')
    if  GPA=='A+'OR'a+'OR 'A' OR 'a':
       print('5.0')        
#The sample code above always make same output 
'5.0'. No matter what kind of input we enter

#Second sample simple code
    GPA= input('Enter GPA Grade: ')
    if  GPA=='A+' OR GPA=='a+' OR GPA=='A' OR 
        GPA=='a':
        print('5.0')
#The sample code above make the correct output 
when we type the variable(GPA) after OR

Aucun commentaire:

Enregistrer un commentaire