Change #temoerature
tempStr = INPUT ( "Please enter the temperature value with a negative sign")
IF tempStr [-1] in [ 'F.', 'F']:
C = (the eval (tempStr [0: -1]) - 32 ) / 1.8
Print ( "temperature after conversion {:} .2f C" .format (C))
elif tempStr [-1] in [ 'C', 'C']:
F. = 1.8 * the eval (tempStr [0: -1]) + 32
Print ( "temperature after conversion {:} F. .2f" .format (F.))
the else:
Print ( "input error")
Python code indentation required to be consistent with the length of
a single line comment with #
plurality of rows Note '' '' ''
naming convention is not the first letter numbers
reserved temporarily now a total of 33 words learn if elif else import print in for
the string class is represented by a single or double quotes quotes
list is the default type [ ] the
index vs slice
index return a single character using [] Gets a character string of
[-1] retrieves the penultimate character
slice: returns the substring period [1: 3] take 1 [0,-1], but not the string starting from 0 - 1
, there are two string representations: forward and reverse decreasing number AMRIS
Forward Increment Number: 01234 .....
Reverse decrement ID: ...- 5-4-3-2-1
used to determine whether an element in the list
of the evaluation function: eval
can remove the outermost quotes remaining parameters and execute the statement
Obtaining a user input integer, the reference integer value, printout "Hello World", requires:
If the input value is 0, direct output "Hello World"
If the input value is greater than 0, the output mode line of two characters "Hello World" (also a space character)
If the input value is less than 0, the output in a perpendicular manner "Hello World"
temp = eval(input())
if temp == 0:
print("Hello World")
elif temp > 0:
print("He\nll\no \nWo\nrl\nd")
else:
for i in "Hello World":
print(i)
Obtaining user input of a character string, the following format:
M ON A
Wherein, M and N is any number that represents OP an operation expressed as the following four: +, -, *, / (addition, subtraction)
The OP in accordance with the calculation result, the output M OP N, unified storage for 2 decimal places.
注意:M和OP、OP和N之间可以存在多个空格,不考虑输入错误情况。
temp = input()
print("{:.2f}".format(eval(temp)))