Note_Tech

All technological notes.


Project maintained by simonangel-fong Hosted on GitHub Pages — Theme by mattgraham

Python - Input & Print

Back


User Input

print("\n--------input--------\n")
username = input("Enter username:\n>>")
print("Username is: " + username)

Print


print("\n--------print--------\n")


print("\n--------OR--------")
# OR
# return or valuate the fisrt expression when the first expression is true.
# Otherwise, return the second value
print(0 or 1)               # 1
print(1 or 0)               # 1
print(False or 'hey')       # hey
print('hey' or False)       # hey
print('hi!' or 'hey')       # hi!
print('hey' or 'hi!')       # hey
print([] or False)          # False
print(False or [])          # []
print(False or True)        # True
print(True or True)         # True
print(True or 1)            # True
print(1 or True)            # 1

print("\n--------AND--------")
# AND
# return or valuate the second expression when the first expression is true.
# Otherwise, return the first value
print(0 and 1)               # 0
print(1 and 0)               # 0
print(False and 'hey')       # False
print('hey' and False)       # False
print('hi!' and 'hey')       # hey
print('hey' and 'hi!')       # hi!
print([] and False)          # []
print(False and [])          # False
print(False and True)        # False
print(True and True)         # True
print(True and 1)            # 1
print(1 and True)            # True


TOP