SoFunction
Updated on 2024-11-15

Commonly used built-in methods in Python

1. Maximum

max(3,4)  ##The result of the run is4

2. Minimum value

min(3,4)   ##The result of the run is3

3. Summation

sum(range(1,101)) ##look for1~100counterfeit medicines

It is easier to find the sum of even or odd numbers from 1 to 100 using this function.

sum(range(1,101,2))   ## Odd sums between 1 and 100
sum(range(2,101,2))   ##1~100The even sum between

4. Enumeration

Returns the index value and the corresponding value.

for i,v in enumerate('hello'):
  print(i,v)

It is possible to make the indexes corresponding to each of the two strings to be displayed together

s1 = 'abc'
s2 = '123'
for i in zip(s1,s2):
  print(i)
  print(''.join(i))

ok~

summarize

Above is the entire content of this article, I hope the content of this article for your study or work has a certain reference learning value, thank you for your support. If you want to know more about the content please check the following relevant links