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
Search strategies are evaluated along four main dimensions. Name those dimensions and briefly describe each one

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

Satellite Transmission: Satellites use microwave frequencies and techniques. Satellites used for message transmission (as opposed to those, which travel around the earth on st

SOFTWARE EVOLUTION:  As you know that in a computer system both hardware and software complement each other  -  one is of hardly any use without the other. Hence, since the ve

Following are some causes why we use threads in designing operating systems. A process with several threads makes a great server for instance printer server. For the reason that t


Bootstrap loader: The critical programs are loaded into memory by the bootstrap loader at start-up time and will remain resident as long as the computer is running. The bootst


write an algorithm and psuedo code for the operation of the cramer`s rule

The following data set describes whether a given coordinate is on land owned by XX government. (x,y) | Class ------------------------ (1.5,6) | owned (2,5) | owned (3,4) | owned (