Python basics data types

Title: Python Basics: Data Types Date: 2017-10-26 13:26 Modified: 2017-10-30 13:26 Category: Python Tags: python, basics Slug: python-basics-data-types Authors: Max Summary: Integers, floats, and strings.

Integer

print 2, type(2)
print 2/6, type(2/6)
print 2%6, type(2%6)
2 <type 'int'>
0 <type 'int'>
2 <type 'int'>

Float

print 2., type(2.)
print 2.6, type(2.6)
print 2./6, type(2./6)
print 2/6., type(2/6.)
print 2.%6, type(2.%6)
print 2%6., type(2%6.)
2.0 <type 'float'>
2.6 <type 'float'>
0.333333333333 <type 'float'>
0.333333333333 <type 'float'>
2.0 <type 'float'>
2.0 <type 'float'>

String

print 'green tea', type('green tea')
print "green tea", type("green tea")
print '123', type('123')
green tea <type 'str'>
green tea <type 'str'>
123 <type 'str'>