I don’t know how to input two numbers separated by Spaces:

n, m = map(int.input().split())
Copy the code

If the input format is as follows:

3
1 2 3
Copy the code

Code:

n = int(input())
a = []
a = list(map(int.input().split()))
Copy the code

If the input format is as follows:

3
1
2
3
Copy the code

Code:

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
Copy the code

Python functions

  • The function code block begins with the def keyword, followed by the function identifier name and parentheses ().
  • Any passed arguments and arguments must be placed between parentheses, which can be used to define arguments.
  • The first line of the function can optionally use the docstring – to hold the function description.
  • Function content starts with a colon and is indented.
  • Return terminates the function, optionally returning a value to the caller. Return without an expression is equivalent to returning None.

Sample code:

def f(name, score) :
    print(name, score)
    return name+':'+str(score)+'points'

n = input()
s = int(input())
print(f(n,s))

The following three ways seem to be the same.
f(name=n, score=s)
f(score=s, name=n)
f(n, s)
Copy the code

The basics of Python are still far from perfect


Neither of today’s two planned things went well… …

Also want to write a C++ experiment report, unfortunately see class this pointer read for a long time to understand, and nearly ten o ‘clock, or get ready to sleep.

It won’t be tomorrow