Home / Interview / python :: General Questions

Interview :: python

51) How can you convert a number to string?

We can use the inbuilt function str() to convert a number into a string. If you want an octal or hexadecimal representation, we can use the oct() or hex() inbuilt function.

52) Mention the rules for local and global variables in Python?

Local variables: If a new value is assigned by a variable within the function's body, it is assumed to be local.

Global variables: These are the variables that are only referenced inside a function are implicitly global.