Data Type Conversion, Basic Computer Science

Sometimes you may drop to perform conversions among the built-in types. To translate between types you just use the type name as a function.
There are quite a few built-in functions to carry out conversion from one data type to another. These functions return a new object representing the changed value.
Function Description
Converts x to an integer. Base states the base if x is a string.
long(x [,base] ) Converts x to a long integer. Base identifies the base if x is a string.
float(x) Changes x to a floating-point number.
complex(real [,imag]) Generates a complex number.
str(x) Changes object x to a string representation.
repr(x) Changes object x to an expression string.
eval(str) Estimates a string and returns an object.
tuple(s) Changes s to a tuple.
list(s) Changes to a list.
set(s) Translates s to a set.
dict(d) Generates a dictionary. d must be a sequence of (key, value) tuples.
frozenset(s) Translates s to a frozen set.
chr(x) Translates an integer to a character.
unichr(x) Translates an integer to a Unicode character.
ord(x) Translates a single character to its integer value.
hex(x) Translates an integer to a hexadecimal string.
oct(x) Translates an integer to an octal string.
Posted Date: 5/5/2012 3:59:55 AM | Location : United States







Related Discussions:- Data Type Conversion, Assignment Help, Ask Question on Data Type Conversion, Get Answer, Expert's Help, Data Type Conversion Discussions

Write discussion on Data Type Conversion
Your posts are moderated
Related Questions
what is member dereferencing oprator ?

Printer output : Consider what is required here. Do you just require management information on the one hand or camera copy for reprographic purposes? Inkjet Very quiet. C

The 21H function and the 22H function of the 21H interruption are the ones in charge of realizing the random readings and writings in that order. The random register number and the

File Organization There are three types of file organization used in practice. Let us consider the example of a dictionary. The dictionary contains listing of English wo

Question 1 Explain synchronous and asynchronous Data Replication Question 2 Write a short note on Access Time, Latency, Transfer Time, and Streaming Tape Question 3

Modify the class declaration of the Employee class to specify that the Employee class is an abstract class Declare an abstract method called CalculateNetPay that returns a double v

Question 1 What are the five subscriber-related signaling functions performed by the operator? Question 2 Compare Microprogrammed control and Hard-wired control Que

Output Devices Video Display Unit (VDU) or Monitor Video Display Unit is similar to a television. It is used to display the results of processes. The screen is il

ARINC 429 DATA Bus SPECIFICATIONS: ARINC 429 sets specifications for the transfer of digital data between aircraft electronic system components and is a "One-way" communication

What is CAI? Explain its pitfalls