Jan-31-2018, 07:41 PM
I am a beginner and im trying to learn python for project with my brother.
Here is the code
input "Name" output
Justin What is your favorite color?
justin what is your favorite color?
"anything else" your lying to me but lets continue
what is your favorite color?
input "Color" output
Orange who is your favorite sibling?
orange who is your favorite sibling?
"anything else if answered "Name" correctly your lying to me but lets continue
who is your favorite sibling?
"anything else if answered "Name" incorrectly again with the lying... but lets keep going'
input "Favorite" output
Isaac correct
So your name is "Name input" , your favorite color is "Color input" , and your favorite sibling is "Favorite input"
Please re-run this program using many different names, colors, etc. It shouldn't matter if it's capitalised or not because i made it that way
isaac correct
So your name is "Name input" , your favorite color is "Color input" , and your favorite sibling is "Favorite input"
Please re-run this program using many different names, colors, etc. It shouldn't matter if it's capitalised or not because i made it that way
"Anything else" Incorrect. Try again (this should repeat after each attempt until correct input, in which case it will then print the above lines)
Here is the code
""" so im learning python for a project with justin so i decided to see if i could remember what i learned so far by making a this little program. then i could show justin where im at and he can proceed with the project accordingly. See attached text file for input/output table """ A="You're lying to me but lets continue" B="Again with the lying... but lets keep going" def lie1or2 (x): if x != "Justin" and x != "justin": return False if x == "Justin" and x == "justin": return True print("So this is a little dealy I made to try and test what I learned so far and to see if it will run on " "your computer. Just fill in what it asks you.") print(" ") #just to add a space Name= input("What is your name?") if Name != "Justin" and Name != "justin": #makes it so he can type in with OR without caps print(A) #your lying to me but lets continue Color= input("What is your favorite color?") if Name == "Justin" and Name == "justin": #answer was as expected continue collecting info Color = input("What is your favorite color?") lie1or2(Name) #calling function lie1or2 with input NAME i think? if Color != "Orange" and Color != "orange": #why cant the first "color" be defined? Isnt it defined above? while lie1or2 is True: print(A) Favorite = input("Who is your favorite sibling?") break if Color != "Orange" and Color != "orange": while lie1or2 is False: print(B) Favorite = input("Who is your favorite sibling?") break Favorite = input("Who is your favorite sibling?") #i shouldnt need this right? but it doesnt work without it. if Color == "Orange" and Color == "orange": Favorite = input("Who is your favorite sibling?") while Favorite != "Isaac" and Favorite != "isaac": print("Incorrect. Try again") Favorite = input("Who is your favorite sibling?") # this should loop until correct input. this is problem right? while Favorite == "Isaac" and Favorite == "isaac": print("Correct!") print(" ") print("So your name is",Name,",your favorite color is",Color,",and your favorite sibling is",Favorite,"") print(" ") print("Please re-run this program using many different names, colors, etc. It shouldn't matter if it's capitalised " "or not because i made it that way.") breakand heres the input/output table of what it should do.
input "Name" output
Justin What is your favorite color?
justin what is your favorite color?
"anything else" your lying to me but lets continue
what is your favorite color?
input "Color" output
Orange who is your favorite sibling?
orange who is your favorite sibling?
"anything else if answered "Name" correctly your lying to me but lets continue
who is your favorite sibling?
"anything else if answered "Name" incorrectly again with the lying... but lets keep going'
input "Favorite" output
Isaac correct
So your name is "Name input" , your favorite color is "Color input" , and your favorite sibling is "Favorite input"
Please re-run this program using many different names, colors, etc. It shouldn't matter if it's capitalised or not because i made it that way
isaac correct
So your name is "Name input" , your favorite color is "Color input" , and your favorite sibling is "Favorite input"
Please re-run this program using many different names, colors, etc. It shouldn't matter if it's capitalised or not because i made it that way
"Anything else" Incorrect. Try again (this should repeat after each attempt until correct input, in which case it will then print the above lines)