Home  >  Article  >  Backend Development  >  How to output the maximum value when inputting ten numbers in python

How to output the maximum value when inputting ten numbers in python

coldplay.xixi
coldplay.xixiOriginal
2020-10-20 10:13:3425192browse

How to input ten numbers in python and output the maximum value: 1. If it is an integer, use the function [a, b, c = map(int, input().split())]; 2. Use Function [X=input().split()].

How to output the maximum value when inputting ten numbers in python

Related free learning recommendations: python video tutorial

How to input ten numbers in python and output the maximum value:

First method:

If you have limited input For integers, you can use the following function:

a, b, c = map(int, input().split())

1. Enter a number directly m = int(input())

2. Entering two numbers is m, n = map(int, input().split())

3. Three or more numbers are Similar to the two:

a, b, c = map(int, input().split())

a, b, c, d = map(int, input( ).split())

How to output the maximum value when inputting ten numbers in python

How to output the maximum value when inputting ten numbers in python

Because when using this function, you must give it in front of how many numbers you want to enter. Corresponding number parameters, so it will be more inconvenient when you want to input a large number of integers

Second type:

X=input().split()

This method is the most concise, clear and convenient. Compared with the first method, you can enter any integer without any restrictions.

How to output the maximum value when inputting ten numbers in python

How to output the maximum value when inputting ten numbers in python

Third method:

This method is mainly used to determine the largest number in a string, even if there are other characters such as spaces or commas.

How to output the maximum value when inputting ten numbers in python

How to output the maximum value when inputting ten numbers in python

How to output the maximum value when inputting ten numbers in python

The above is the detailed content of How to output the maximum value when inputting ten numbers in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn