TIME NOW CALENDAR CONVERT LENGTH CONVERT TEMPERATURE DICTIONARIES, LISTS SCIENCE EDUCATION RELIGION WORK CALCULATOR CALCULATE LIFE

# Python 3 programming language, learn python, tutorial

ALL TOPICS

## Python 3. if condition, statement

py = 10, po = 20
• ==      (py == po) is not true.
• !=       (py != po) is  true.
• <>      (py <> po) is true.
• >        (py > po) is not true.
• <        (py < po) is true.
• >=      (py >= po) is not true.
• <=      (py <= po) is true.
1. Simpliest condition:
x=10
if x < 0:
x=1
print (x)

x = 10

if x < 0:
x=1
print (x)

1a. if condition example:
x = int(input("Please enter a number: "))

if x < 0:
x = 0
print('Data < 0')
elif x == 0:
print('Data = 0 ')
elif x == 1:
print('Data = 1 ')
else:
print('Data > 0')

2. Indentation:
if True:
print ("Yes")
else:
print ("No")

3. Indentation:
if True:
print ("True")
else:
print ("False")

Result:
C:\Python34>python hello.py
File "hello.py", line 6
print ("False")
^
IndentationError: unindent does not match any outer indentation level

4. Condition in the one row:
var = 100
if ( var  == 100 ) : print ("Value of expression is 100")

ALL TOPICS

 Andrius:1. x = int(input("Iveskite norima x reiksme: "))y = int(input("Iveskite norima y reiksme: "))if x > y: print("Didesnis x - %d" % x)elif x == y: print("x ir y yra lygus")else: print("Didesnis y - %d" % y)2. x = int(input("Iveskite norima x reiksme: "))y = int(input("Iveskite norima y reiksme: "))c = intc = x + yif c == 10: print("Atsakymas lygus 10") print(c)elif c > 10: print("Atsakymas didesnis uz 10") print(c)else: print("Atsakymas mazesnis uz 10") print(c)2015-10-28 06:32:46
 Vitalij:x = int(input("Atspek skaiciu. Jusu skaicius: "))if x<0 or x>10: print("Iveskite skaiciu nuo 0 iki 10")elif x==5: print("atspejote skaiciu")else: print("neatspejote skaiciu")a,b,c =input("Iveskite 3 skaicius: ").split()if a>b: if a>c: print("didziausias ivestas skaicius: ",a) else: print("didziausias ivestas skaicius: ",c)else: if b>c:print("didziausias ivestas skaicius: ",b) else: print("didziausias ivestas skaicius: ",c)2015-10-28 09:09:18
 Mindaugas:print ("=================pirmas pavyzdys=================")var = 100if var == 200:   print ("1 - Got a true expression value")   print (var)elif var == 150:   print ("2 - Got a true expression value")   print (var)elif var == 100:   print ("3 - Got a true expression value")   print (var)else:   print ("4 - Got a false expression value")   print (var)print ("Good bye!")print("==================antras pavysdys=================")people = int(input("Enter people count: "))cars = int(input("Enter cars count: "))trucks = int(input("Enter trucks count: "))if cars > people:    print ("We should take the cars.")elif cars < people:    print ("We should not take the cars.")else:    print ("We can't decide.")if trucks > cars:    print ("That's too many trucks.")elif trucks < cars:    print ("Maybe we could take the trucks.")else:    print ("We still can't decide.")if people > trucks:    print ("Alright, let's just take the trucks.")else:    print ("Fine, let's stay home then.")print("=============trecias pavyzdys====================")person = input("Nationality? ")if person == "french" or person == "French" :    print("Préférez-vous parler franēais?")elif person == "italian" or person == "Italian":    print("Preferisci parlare italiano?")else:    print("You are neither Italian nor French,")    print("so we have to speak English with each other.")2016-04-19 12:09:01
 Paulius:#!/usr/bin/python # # Python program to generate a random number with commentary. #   # Import is much like Java's.  This gets the random number generator. import random   # Generate a random integer in the range 10 to 49. i = random.randrange(10,50) print 'Your number is', i   # Carefully analyze the number for important properties. if i < 20:     print "That is less than 20."     if i % 3 == 0:         print "It is divisible by 3." elif i == 20:     print "That is exactly twenty.  How nice for you." else:     if i % 2 == 1:         print "That is an odd number."     else:         print "That is twice", i / 2, '.'     print "Wow! That's more than 20!"2016-05-03 11:16:29