PYTON



 USE DESKTOP MODE FOR BETTER EXPERIENCE ***THANK YOU***    

                                

👇
                  
                                                                    PYTHON FULL COURSE
                                                                    PY EXAMPLES



 

# This program prints Hello, world!

 

Print(‘Hello, world!’)

O/p

Hello, world!

2.# This program adds two numbers

 

Num1 = 1.5

Num2 = 6.3

 

# Add two numbers

Sum = num1 + num2

 

# Display the sum

Print(‘The sum of {0} and {1} is {2}’.format(num1, num2, sum))

Run Code

Output

 

The sum of 1.5 and 6.3 is 7.8

3

 Python program to 

# demonstrate numeric value

 

 

 

A = 5

 

Print(“Type of a: “, type(a))

 

 

 

B = 5.0

 

Print(“\nType of b: “, type(b))

 

 

 

C = 2 + 4j

 

Print(“\nType of c: “, type©)

Output:

 

Type of a:  <class ‘int’>

 

Type of b:  <class ‘float’>

 

Type of c:  <class ‘complex’>

4

# Python program to illustrate

# while loop

 

Count = 0

 

While (count < 3):

 

    Count = count + 1

 

    Print(“Hello Geek”)

Output:

 

Hello Geek

Hello Geek

Hello Geek

5

# Python program to illustrate

# combining else with while

 

Count = 0

 

While (count < 3):

 

    Count = count + 1

 

    Print(“Hello Geek”)

 

Else:

 

    Print(“In Else Block”)

Output:

 

Hello Geek

Hello Geek

Hello Geek

In Else Block

Post a Comment

0 Comments

Recent, Random or Label