Last active
December 4, 2018 12:01
-
-
Save mobileappconsultant/6f365068bea2083b17615412b5840f43 to your computer and use it in GitHub Desktop.
Basic python script to practice some basic syntax in python version 3.5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Different ways to test multiple | |
# flags at once in Python | |
x, y, z = 0, 1, 0 | |
if x == 1 or y == 1 or z == 1: | |
print('passed') | |
if 1 in (x, y, z): | |
print('passed') | |
# These only test for truthiness: | |
if x or y or z: | |
print('passed') | |
if any((x, y, z)): | |
print('passed') | |
#Check is any of x,y,z exists in numbers | |
numbers= [1,2,3,4,5,6,7,8,9] | |
if any((x,y,z)) in numbers: | |
print("We found either x,y or z in numbers") | |
#Merge two dictionaries | |
x ={"a": 1,"b" : 2} | |
y = {"b": 3,"c": 4} | |
z = {**x, **y} | |
print(z) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment