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
QUESTION (a) Give the two conditions required by a binary tree of depth d to be an almost complete binary tree. (b) Determine what the following recursive C function compute


#questionWrite a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two poi

Data Processing In any computer-based system, data storage and retrieval plays an important role. Data storage involves decision about the encoding of data, assignment o

Basic steps/tasks involved in spreadsheets development

Question 1 Explain the concept of knowledge discovery in database Question 2 Discuss the following types of Multidimensional Data Models                    Stars, Snowflakes and

MAGNETIC CORE MEMORY: This type of memory is used extensively in airborne digital systems, although integrated circuits are being developed with most modern aircraft systems.

short note about extension..

When software is installed onto a modern day personal computer (most commonly from a CD-ROM, though other media or downloading from the internet is also common), code comprising th

Word Processing (WP): Word Processing is one of the most widespread application software types in use today. Developed as a successor to primitive text editors that were popul