#!/usr/bin/python3 # -*- coding: utf-8 -*- # Converting between types: """ int() Creates integers int, float, strings w/ integers only Truncates float """ # These two work: print(int(4.7)) print(int("4")) print(int("4.7")) # ValueError: invalid literal for int() with base 10: '4.7' """ float(x) Converts x to a floating-point number. int, float, strings w/ integers or fractions """ print(float(4)) print(float("4")) print(float("4.3")) """ str(x) Converts object x to a string representation. Any repr(x) Converts object x to an expression string. Any These are meant for computational evaluation, similar to str """ print(str(4.0)) print(str(4)) print(str([4, 2, 1])) """ complex(real [,imag]) Creates a complex number. """ complex(3, 6) type(complex(3, 6))