5. Variables and Typecasting : Python

Variables And Typecasting

Variable - A variable is a name given to any capacity region or memory area in a program. 

Variables in Python

Rules for characterizing a variable in Python

  • A variable name can contain letters in order, digits, and highlights (_).
  • A variable name can just begin with a letter in order and highlight. 
  • It can't begin with a digit. For instance, 5david is illicit and not permitted. 
  • No blank area is permitted to be utilized inside a variable name. 
  • Held Keywords are not prescribed to be utilized as factor names. 


type() Function in Python - It is a capacity that permits a client to observe the information sort of any factor. It returns the information sort of any information contained in the variable passed to it. 


Note

  • We can't do numbers with strings number-crunching tasks, i.e., we can't add a string to any number. 
  • We can add (connect) at least two strings, and the strings will be linked to return another string. 


Typecasting - This is the method for transforming one information sort of any information or variable to another datatype, i.e., it changes the information kind of any factor to some different information type. 


input() Function - This capacity permits the client to get input from the console into the program as a string.

Post a Comment

0 Comments