go to 1, 2, 3, 4
Python: print statement, string, integer, float, real number, fraction, decimal, operator
Python: print statement, string, integer, float, real number, fraction, decimal, operator
![]() |
| Python shell with prompt |
' >>> ' means it is ready to read statement ( you can type something on it )
( known as prompt )
type print 'hello world'
also this can make sure the Idle is installed correctly.
print statement can print string literal, and every string values are enclosed in quotes
as you can see, print statement can recognize double quotes and single one.
another way to do this is to use following.
to make new line within one statement is
to set up tab space
as you know, integers are 1, -1, 23545 ... does not have fractional part ( decimal point )
real number are 3.1415.. (pi), -2.4 .... does have fractional part or in Python it could means integer+ decimal point. for example, 2. , -412.
even if numbers after the decimal point does not exist, python will accept as real number.
1.241E12 represent 1.241 x 10^12
2.42e-4 represent 2.42 x 10^-4
then you can print number using print statement
next thing is arithmetic operator !
1. exponentiation : 2**4 means 2^4 , that is 16.
3,4 sign or sub,add : this will be ordered by how you do that
5,6 : division. in Python, division only calculate integer part if and only if operands are integer. if you want to get fractional part of division, should use float('operand')
example below:
note that second division operator will replace your fractional part even if you used float().
and wherever you use float(operand), Python will accept as real number, not a integer.
( float(14) / 5 <-> 14 / float(5) )









No comments:
Post a Comment