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
how we come to know about primary key,if more than ids gather?

Question 1 Discuss the impacts of disaster faced by the organization Question 2 Explains the steps involved in disaster recovery planning Question 3 What do you mean by

Write a method called Grade that takes a numeric score and returns a letter grade. Use the rule that 90 to100 is an A, 80 to 89 a B, 60 to 79 is a C, 45 to 59 is a D, and less th

difference between recursion and iteration

Concept of operating system: An operating system is an essential software component of a computer system. The basic  objectives of an operating system are to make the computer

TELECOMMUNICATION PROTOCOLS: The two major components relating to a WAN are the Protocol and the Media. The media are the actual path ways that the protocol travels on. The ne

The skill of Assembly Language Programming (AoA), Randy Hyde''s acclaimed text on assembly language programming, is the most-frequently recommended book on 80x86 assembly language

Long term goal of artificial intelligence: This is not to be complex with the applications of AI programs to other sciences, discussed later. Rather, it is just pointing out th

Give a topology (network diagram) in which there is a link whose failure will change many routes. Give one in which there is a link whose failure will not change any routes

Liquid Crystal Displays (LCD): First introduced in watches and clocks in the1970's, LCDs are now used to display images in monitors. A newer technology in computer screens is