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
Data buses: The availability of reliable digital semi-conductor technology has enabled the inter-communication task between different equipment to be significantly improved. P

Nano programming using microcontrol and circuits

1. What actions need to be taken when a program terminates or a process is killed? What if that process destruction is not the consequence of normal termination, but rather is the

Question: Imagine that you are part of a design team creating a new mobile phone for people such as "Angel White" whose persona is given below: Angel is turning 90 years old

I need someone to help me with my Unix/Linux homework.

write a program of circle of any colour

Mike sells on the average 15 newspapers per week (Monday – Friday). Find the probability that 2.1 In a given week he will sell all the newspapers [7] 2.2 In a given day he will sel

what are the phases of oo progarmming or java?

write algorithm and draw flowchart to check whether the given number is palindrome or not

How do I change file permissions? Every time I execute chmod commands it tells me permission denied.