In [1]:
print('Hello world')
In [2]:
str = 'Hello World!'
print(str)
In [3]:
from random import choice
a = choice(range(1000))
b = choice(range(1000))
In [4]:
print('{} plus {} is: {}'.format(a, b, a + b))
In [5]:
print('{1} plus {0} is: {2}'.format(a, b, a + b))
In [6]:
print('{0:3} plus {1:3} is: {2:3}'.format(a, b, a + b))
In [7]:
print('{:6} plus {:6} is: {:6}'.format(a, b, a + b))
In [8]:
print('{:06.2f} plus {:08.2f} is: {:7.2f}'.format(a/2, b/2, a + b))
In [9]:
print('{} is {}'.format(a, 'odd' if a % 2 else 'even'))
In [10]:
statement = 'name: {}, email: {}, #phone: {}'
values = {'name': 'Arthur king of the britons', 'email': 'king.arthur@britons', 'phone': '(42) 232323'}
print(statement.format(
values['name'],
values['email'],
values['phone']
))
In [11]:
a = input()
In [12]:
a = input()
type(a)
Out[12]:
In [13]:
a = input('Digit a positive number: ')
type(a)
Out[13]:
In [14]:
a = int(input('Digit an integer '))
b = int(input('Digit another integer '))
print('{} plus {} is: {}'.format(a, b, a + b))