24
loading...
This website collects cookies to deliver better user experience
print("Hello world")
python app.py
Hello world
# This is a single line comment
'''
This is a multiline comment
'''
variable_name = variable_value
First_number = 1
print(First_number)
output: 1
1rst_num = 1
print(1rst_num )
output :Syntax Error: invalid syntax
# Addition
5 + 3
8
# Subtraction
>>> 5 - 3
2
Multiplication
5 * 3
15
# Division
5 / 3
1.6666666666666667
# Floor division
5 // 3
1
# Modulus (returns the remainder from division)
5 % 3
2
# Power
5 ** 3
125
2 < 5
True
4 > 10
False
bool(0)
False
bool(1)
True
int(False)
0
int(True)
1
# Use single quotes
print('Hello there!')
'Hello there!'
#Use double quotes
greeting = "Good Morning!"
print(greeting)
'Good Morning!'
# Use triple quotes
message = """Thanks for joining us!"""
print(message)
'Thanks for joining us!'
print("Happy" + " " + "Holidays!")
'Happy Holidays!'
"Happy Holidays!".upper()
'HAPPY HOLIDAYS!'
" ".join(["Happy", "Holidays!"])
'Happy Holidays!'
numbers=[1,2,3,4]
print(numbers)
output: [1, 2, 3, 4]
numbers=[1,2,3,4]
numbers.append(5)
print(numbers)
output:[1, 2, 3, 4,5]
a = ['a', 'b']
a.extend([1, 2, 3])
print(a)
['a', 'b', 1, 2, 3]
a = ['name', 'location', 'address','email']
a.insert(3, 20)
print(a)
['name', 'location', 'address', 20, 'email']
a = ['name', 'location', 'email', 'address']
a.remove('email')
print(a)
['name, 'location', 'address']
new_tuple=(1,2,3,4)
print(new_tuple)
output: (1, 2, 3, 4)
new_dict = {"name": "Korir", "Email": "[email protected]",
"DOB": 2000}
print(new_dict["Email"])
output:"[email protected]"