input and if-else

21 0 2
                                        


input, is the thing you put in -holdup

I mean

Anything you type or information given by user to the computer is considered input.

for python we use:- 

input tag

a=input("what is your name?")

basically what this is saying is

input('what is your name')

it is asking for your name. 

the 

what is your name will show up as question in terminal. where you can actually answer it.Unlike print which you can't answer it.

a here is a variable right. 


so when you answer the question.

My name is DFOCMARU

a will be 

a="My name is DFOCMARU"


***


NOTE:- # means comment in python.


print("Hello world!") this will show in terminal
#print("Hello world") this won't show in terminal



ALR NOW FOR IF-ELSE STATEMENT, LETS DO SMALL PROGRAM TO CHECK IF USER IS ELIGIBLE TO DRIVE. OF COURSE I WILL EXPLAIN THE PROGRAM. 


age = int(input("Enter your age: "))


if age >= 18: 

print(" You are eligible to drive!") 

else: print("go to school kid.")


***
explanation
***


age = int(input("Enter your age: "))      #means the program is asking for the input, it has to be                                                                                     age and number. and  it will be directly stored in age                                                                                              variable.


if age >=18             # means program is checking whether the inputted age is 18 or above. if user is                                         above 18 or is 18 they can drive.

else:                            # means, it is anything but above 18 or 18, go back to school



A little challenge
WRITE A PROGRAM THAT ASKS FOR SECRET CODE AND IF THE CODE IS CORRECT, THE DOOR OPENS ELSE THE ACESS IS DENIED.

NIGHT

NIGHT

Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.
PYTHON JOURNEY BY BEGINNERWhere stories live. Discover now