Q:

Python | Program to define an integer value and print it

belongs to collection: Python basic programs

0

Define an integer value in a variable and print it in Python.

Its very simple to declare a variable and define an integer value to it, there is no need to define any type of keyword to make the variable an integer, we have to just assign an integer value and variable is able to store and then we can print it.

Syntax:

 variable_name = value

Example:

If we want to assign 10 to a variable named num, the statement will be:

 num = 10

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

# Python program to define an 
# integer value and print it 

# declare and assign an integer value 
num = 10

# print num 
print "num =",num 
# print using format
print "num = {0}".format(num)

# assign another value
num = 100

# print num 
print "num =",num 
# print using format
print "num = {0}".format(num)

Output

    num = 10
    num = 10
    num = 100
    num = 100

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python basic programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Python | Input two integers and find their additio... >>
<< How to check multiple variables against a value in...