Python Program to initialize different datatypes and print
Program
a = 10
b = 20.25
c = 'a'
d = "John"
print("Integer type = ", a)
print("Floating point type = ", b)
print("Character type = ", c)
print("String type = ", d)
This program demonstrates how to initialize different data types in Python and print their values.
a = 10
b = 20.25
c = 'a'
d = "John"
-
Integer (
int
):a = 10
→a
is an integer (whole number).
-
Floating-point (
float
):b = 20.25
→b
is a floating-point number (decimal value).
-
Character (
str
with a single character):c = 'a'
→c
is a string containing a single character.
-
String (
str
):d = "John"
→d
is a string (sequence of characters).
print("Integer type = ", a)
print("Floating point type = ", b)
print("Character type = ", c)
print("String type = ", d)
- The
print()
function displays the values stored in each variable.
Output
Integer type = 10
Floating point type = 20.25
Character type = a
String type = John