Computer Science, asked by arshkalsi1888, 11 months ago

Define the following variables in a Python script and print the type of each variable in separate lines. x = 6 y = 12 m = 0b1011 n = 0xad4

Answers

Answered by codiepienagoya
0

The program to this question can be given as:

Program:

#define variable and assign value

x = 6

y = 12  

m = 0b1011  

n = 0xad4

# finding data type of variables.

print('Variable x =',x)  #print value.  

print('Type of x is =',type(x))    #print type.

print('Variable y =',y)  #print value.  

print('Type of y is =',type(y))    #print type.

print('Variable m =',m)  #print value.  

print('Type of m is =',type(m))    #print type.

print('Variable n =',n)  #print value.  

print('Type of n is =',type(n))    #print type.

Output:

Variable x = 6

Type of x is = <class 'int'>

Variable y = 12

Type of y is = <class 'int'>

Variable m = 11

Type of m is = <class 'int'>

Variable n = 2772

Type of n is = <class 'int'>

Explanation:

As we know Python is a dynamically types language. In python, we do not need to declare any data type it automatically find the data type of variable.

  • In this program, we define a variable that is x,y,m, and n. In this variable we assign value.
  • Then we print the value of the variable.
  • To print the type of the variable we use the type() function. In this function, we pass an object or variable as a parameter and print it. So, it will return the type of the variable.

Learn more:

What is variable in python: https://brainly.com/question/13281511

Answered by poojan
0

Python program to print the type of the variable

Program:

x=6

print("Type of ",x," is : ",type(x))

y=12

print("Type of ",y," is : ",type(y))

m=0b1011

print("Type of ",m," is : ",type(m))

n=0xad4

print("Type of ",n," is : ",type(n))

Output:

Type of  6  is :  <class 'int'>

Type of  12  is :  <class 'int'>

Type of  11  is :  <class 'int'>

Type of  2772  is :  <class 'int'>

Explanation :

  • All the datatypes in the python are the class objects.

  • The function type(variable/value) is used to know the type of value present in the variable.

  • On assigning the values to the variables statically, pass them through the type() that tells you the type of the value.

Learn more :

1) What is python programming?

https://brainly.in/question/8474677

2) Python program to make a calculator.

https://brainly.in/question/14752569

Attachments:
Similar questions