Input
print('Hello World!')


Python Online Compiler


This is an Online Python Compiler for the practice purpose. If you want to learn and practice Python programming basics , no need to install Python IDE on your computer, just use this online IDE.

Below are some of the Python programming examples.



Dealing with strings


first_name = 'Python'
last_name = 'Programming'
print(first_name + ' ' + last_name)

Here we are concatenating two strings with space between both the strings. The output will be 'Python Programming'



Operating numbers


A = 70
B = 30
SUM = A + B
SUB = A - B
MUL = A * B
DIV = A / B
print(SUM)
print(SUB)
print(MUL)
print(DIV)

It will give the output as: 100 40 2100 2.333



If Else statement


a = 34
b = 33
if b > a:
    print('b is greater than a')
elif b < a:
    print('b is smaller than a')
else:
    print('a and b are equal')

It will give the output: b is smaller than a



For Loop


language = ["JavaScript", "React", "Python"]
for x in language:
    print(x)

The output will be: Javascript React Python



While Loop


i = 1
while i < 8:
    print(i)
    i += 1

The output will be: 1 2 3 4 5 6 7



Arrays


product = ['laptop', 'mobile', 'tablet', 'PC']
    print(product[1])

The output will be: mobile



Finding Factorial of a number


num = 5
factorial = 1
if num < 0:
    print("factorial for negative numbers does not exist")
elif num == 0:
    print("the factorial of 0 is 1")
else:
    for i in range(1,num + 1):
        factorial = factorial*i
    print("the factorial of", num, "is", factorial)

The output will be: 120. You can change the num value according to your needs.