Sign in to follow this  
mesvak

[ttrial] "IF" AND conditions ON Py thing u needa be carefull and know them

Recommended Posts

[hide]

 

Condition in python
#mesvak is not ur lil gae bish
age = 12
name = 'mesvak'
language = 'python'

if age == 12:
   print("age is 12")
#output : age is 12

if age is 12:
   print("age is 12")
#output : age is 12

if age == 13:
   print("ok")
else:
   print("less than 13")
#output : less than 13

if age == 14:
   print("age is 14")
elif age == 13:
   print("age is 13")
elif age == 12:
   print("age is 12")

if age is not 13:
   print("age is not 13")
#output : age is not 13

if age >= 12:
   print("ok")
#output : ok

if age <= 13:
   print("ok")
#output : ok

if age != 12:
   print("ok")
# it wont be executed cuase mesvak age is 12 and its opposite 

if name == 'mesvak' and age == 13:
   print("welcome1")
#output : this wont be executed cuase age is not 13 

if name == 'mesvak' or age == 13:
   print("welcome")
#output : welcome there is or 

if name == 'mesvak' and (age == 14 or language == 'python'):
   print("welcome")
#output : welcome

lst = [1, 2, 3 , 4]
if 1 in lst:
   print("1 is in list")
#output : 1 is in list

if 6 not in lst:
   print("6 is not in list")
#output : 6 is not in list

age = 14
name = "mesvak" if age < 12 else "suck"
print(name)
#output : suck

name = 'mesvak' if age < 15 else 'mesvak' if age > 15 else 'nigger'
print(name)
#output : mesvak

if age < 15:
   if age > 15:
       print('vmesvak')
   else:
       print('mesvak')
else:
   print('nigger')
#output : mesvak

name = (('vmesvak', 'suck')[age > 12])
print(name)
#output : suck

name = (('vmesvak', 'suck')[True])
print(name)
#output : suck true means age == 14

name = ('nigger', 'babak')[age < 12]
print(name)
#output : nigger
or 
name = ('nigger', 'babak')[False]
#output : nigger

name = (age < 20) and 'mesvak' or 'nigger'
print(name)
#output : mesvak

name = {True: 'mesvak', False: 'nigger'}[age < 20]
print(name)
#output : mesvak

name = ((age > 20) and ['mesvak'] or ['nigger'])
print(name)
#output : ['nigger']

name = ((age > 20) and ['mesvak'] or ['nigger'])[0]
print(name)
#output : nigger

x = [True, True, False]
if any(x):
   print("At least one True")
#output : At least one True

if all(x):
   print("Not one False")
else:
   print("At least one False")
#ouput : At least one False

if any(x) and not all(x):
   print("At least one True and one False")
#output : At least one True and one False

 

 

 

[/hide]

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this