Python 3 Tutorial: 10 - If statement

preview_player
Показать описание
The famous if statement, along with the elif and else statements
Рекомендации по теме
Комментарии
Автор

Every tutorial that I watch I give you a thumb up in the beginning of the video and I never regretted at the end !!!



Thank you!

RRRooooDDDD
Автор

@clockdud556 colon's are used after statements which require code to follow them, which happen because of them. for instance, if or while statements

TheMonkeyLords
Автор

how to make the guess number random:

*import random
for if statement type
*if guess = random.randint(1, 10):

rest of code is the same, any better ideas?

joellacy
Автор

@3215matt It's actually not that hard. You would need the use the while loop, and something called a counter. What a counter is is just a variable that counts up (or down) each time you loop through. So, something like this:

int i = 10
while i > 0:
//some code here
i-- //This is the shortcut of i = i -1, basically just subtracting one each time

Does this help?

TheMonkeyLords
Автор

thank you so much for these tutorials. question: you use if statements as many times as you want so what's the point of elif statements if it's pretty much the same thing?

chillbabe
Автор

sir after write If Then what did you do before Else because when I type else it comes in Intendation line ?..

Harshujivlogger
Автор

hi i need help!
if for the else part i would like it to print something but then reask the question so the loop repeats how would i do that?

zzza
Автор

Without you I would not be getting the grades i am today!

CCninjazpenguin
Автор

What if i want it to repeat the question until it is right?

abominablegames
Автор

@TakaruXXX I plan on it, I just haven't had time recently. Actually, I think I'm going to make a couple today, so look for some up early this weekend.

TheMonkeyLords
Автор

help when i type guess = int(input("guess a number")) and when i press enter guess a number directly comes under this statement

dawoodaijaz
Автор

Can I get the link for the first vedeo

tinotendagoredema
Автор

thanks for this good tutorials my friend :))
i'm a beginner to python and also programming ama that was exactly what i needed (y)

TimurAykutYldrm
Автор

What to do of the person has to guess a text instead of a

piyushgarg
Автор

how does this 'or' thingy work?

Zayaraq
Автор

hi, , little help needed (new to this)

i type in exactly the same code as in 4:46, , , but when i press enter after the print ("you win") the cursor doesnt go back to the left, it remains directl below the word print on the line above, so i cant type 'else' on the left hand side... i think this is why it says 'syntax error when i try and run it

georgemay
Автор

Can this be done with a word instead of a number?

Example-

Wanna know a secret? yes
(and then have it print "Potatoes" if yes, but print "Too bad" if no.

tyomen
Автор

I have a question no video has answered yet. IS IT POSSIBLE TO COMPARE A STRING WITH A WORD!?! LIKE CAN WE DO A WORD GUESSING GAME!?! Please answer since I had this question for TWO FULL DAYS and I still didn't get an answer. ;-(
P.S. Although you may not answer, if someone watching this video knows what the answer is, please tell me since it's killing me!! (Not literally but you get it.)

nickjasperr
Автор

there is somthing wrong with this code it says pizza is undefined 

name = input('Enter your name: ')
print ('Hello', name)
surname = input ('Enter your surname: ')
print ('Your intials are: ', name[0], surname[0])
food = input('What type of food do you like?: ')
if food == pizza:
    print ('I love', food, 'too!')
else:
    print ('Im not to fond of', food)

vandibox