Test 3: basic data types (Week 3) - the program title

Question 1: square root format

description

Obtaining an integer a, calculates the square root of a user input, 3 digits after the decimal point, and prints.

30 using the output character width, the output right-justified, the extra character is a plus sign (+) is filled.

If the result is more than 30 characters, it is subject to the result width.

Example O

  Entry Export
Example 1
10
+++++++++++++++++++++++++3.162

 answer:

a = eval(input())
print("{0:+>30.3f}".format(pow(a,1/2)))

Question 2: string segment composition

description

Obtaining input a string s, character minus sign (-) split s, compositions in which the two end to end by a plus sign (+) output.

Example O

  Entry Export
Example 1
Alice-Bob-Charis-David-Eric-Flurry
Alice+Flurry

 answer:

s=input()
l=s.split('-')
print(l[0]+'+'+l[-1])

  

Guess you like

Origin www.cnblogs.com/qiuniao/p/11969866.html