print ("Hello World !")
Hello World !
A little variable practice...
# A little variable practice...
d = input("How much gas do you want in your car? It must be less than 11 liters. - ")
c = int(d)
if (c >= 7 ):
print ("Your car has a good amount of fuel!")
elif (c >= 4 ):
print ("You might need to fill up your gas tank soon!")
elif (c >= 1 ):
print ("Hurry! Fill up now!")
else:
print ("Out of fuel!")
How much gas do you want in your car? It must be less than 11 liters. - 8 Your car has a good amount of fuel!
#This is my madlib example
adj1 = input("Type in an adjective - ")
n1 = input("Type in a noun - ")
pverb1 = input("Type in a verb (Past tense) - ")
adv1 = input("Type in an adverb - ")
adj2 = input("Type in an adjective - ")
n2 = input("Type in an noun - ")
n3 = input("Type in an noun - ")
adj3 = input("Type in an adjective - ")
verb1 = input("Type in a verb - ")
adv2 = input("Type in an adverb - ")
pverb2 = input("Type in a verb(Past tense) - ")
adj4 = input("Type in an adjective - ")
mymadlib = "Today I went to the zoo. I saw a %s %s jumping up and down in its tree.He %s %s through the large tunnel that led to its %s %s. I got some peanuts and passed them through the cage to a gigantic gray %s towerng above my head. Feeding that animal made me hungry. I went to get a %s scoop of ice cream.It filled my stomach. Afterwards I had to %s %s to catch the bus.When I got home, I %s my mom about the %s day at the zoo " %(adj1, n1, pverb1, adv1, adj2, n2, n3, adj3, verb1, adv2,pverb2, adj4)
print (mymadlib)
Type in an adjective - cool Type in a noun - monkey Type in a verb (Past tense) - ran
#This is my test example
Correct = 0
start = input("Do You want to play Trivia? (Y or N) - ")
if (start == "Y" ):
Q1 = input ("Okay. What is the capital of the United States of America ? ")
if (Q1 == "Washington D.C."):
print ("Correct!")
Correct = Correct + 1
else:
print ("Sorry, That's incorrect!")
Q2 = input ("Next question. What is the tallest mountain in the world ? ")
if (Q2 == "Mount Everest"):
print ("Correct!")
Correct = Correct + 1
else:
print ("Sorry, That's incorrect!")
Q3 = input ("Alright, next question. What is the largest ocean in the world (Capitalize Ocean) ? ")
if (Q3 == "Pacific Ocean" ):
print ("Correct !")
Correct = Correct + 1
else:
print ("Sorry, That's incorrect !")
Q4 = input ("Well, let's continue. What is 8 * 3 ? ")
if ( Q4 == "24"):
print("Correct!")
Correct = Correct + 1
else:
print("Sorry, That's incorrect!")
Q5 = input ("Final question, where is the PyCon 2018 located ? ")
if (Q5 == "Cleveland"):
print("WooHoo, that's correct!")
Correct = Correct + 1
else:
print ("Sorry, that's incorrect!")
ResultAsk = input ("Now, are you ready for your score (Y or N) ?")
if (ResultAsk == "Y"):
result = ("You got %s out of 5 correct! Thanks for trying my trivia!") %(Correct)
print (result)
else:
print ("Okay, that's fine! Have a good time!")
Do You want to play Trivia? (Y or N) - Y Okay. What is the capital of the United States of America ? Washington D.C. Correct! Next question. What is the tallest mountain in the world ? Mount Everest Correct! Alright, next question. What is the largest ocean in the world (Capitalize Ocean) ? Pacific Ocean Correct !
# This is my computer algorithm
start = input ("Hello there. Do you want to try my computer algorithm? (Y or N) - ")
if (start == "Y"):
print ("Okay, get ready!")
import random
guessNum = 0
comNum = random.randint (1,100)
myNum = input ("Okay. I will select a random number from 1 to 100. Then, you may take a guess. If my number is higher than yours, I will return 'Higher'. However, if my number is lower than your number, I will send 'Lower'. Are you ready to start ? (Y or N) - ")
if (myNum == "Y"):
while True:
ask = input ("Okay. I have selected my number. Which number will you choose?")
if (ask < comNum):
print ("Sorry, my number is higher than your number.")
guessNum = guessNum + 1
elif (ask > comNum):
print ("Sorry, my number is smaller than your number.")
guessNum = guessNum + 1
else:
Correct = input ("Correct ! Do you want to play again ? - ")
print(Correct)
guessNum = guessNum + 1
if (Correct == "Y"):
start = input ("Hello there. Do you want to try my computer algorithm? (Y or N) - ")
if (start == "Y"):
print ("Okay, get ready!")
import random
guessNum = 0
comNum = random.randint (1,100)
myNum = input ("Okay. I will select a random number from 1 to 100. Then, you may take a guess. If my number is higher than yours, I will return 'Higher'. However, if my number is lower than your number, I will send 'Lower'. Are you ready to start ? (Y or N) - ")
if (myNum == "Y"):
while True:
ask = input ("Okay. I have selected my number. Which number will you choose?")
if (ask < comNum):
print ("Sorry, my number is higher than your number.")
guessNum = guessNum + 1
elif (ask > comNum):
print ("Sorry, my number is smaller than your number.")
guessNum = guessNum + 1
else:
Correct = input ("Correct ! Do you want to play again ? - ")
print(Correct)
guessNum = guessNum + 1
Hello there. Do you want to try my computer algorithm? (Y or N) - Y Okay, get ready! Okay. I will select a random number from 1 to 100. Then, you may take a guess. If my number is higher than yours, I will return 'Higher'. However, if my number is lower than your number, I will send 'Lower'. Are you ready to start ? (Y or N) - Y Okay. I have selected my number. Which number will you choose?76
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-13-8b8b8afe790c> in <module>() 10 while True: 11 ask = input ("Okay. I have selected my number. Which number will you choose?") ---> 12 if (ask < comNum): 13 print ("Sorry, my number is higher than your number.") 14 guessNum = guessNum + 1 TypeError: '<' not supported between instances of 'str' and 'int'