Saturday, December 22, 2018

python switcher case while else type() format (%s %03d {})

b = 'True'
print(type(b) == str)
print(type(b) == bool)

switcher = {
True: print('it is true'),
1: 'Monday',
2: 'Tuesday',
3: 'Wednesday',
4: 'Thursday',
5: 'Friday',
6: 'Saturday'
}
print(switcher.get(True, 'else'))

a = 3
while (a > 0):
print(a)
a -= 1
else:
print("Reached 0")

# Here age is a string object
age = "18"
print(age)
# Converting string to integer
int_age = int(age)
print(int_age)
age = False
int_age = int(age)
print(int_age)

print('%(language)s has %(number)05d quote types.' % {
"language": "Python",
"number": 2
})
print('form({})'.format(b))

No comments: