## python practice questions

# 1. Title description: An integer, which is a perfect square after adding 100, and a perfect square when adding 168, what is the number?

```
for i in range ( 1 , 84 + 1 ) :
if 168 % i == 0 :
j = 168 / i
if i > j and ( i + j ) % 2 == 0 and ( i - j ) % 2 == 0 :
m = ( i + j ) /2
n = ( i - j ) / 2
x = n * n - 100
print ( "%d" % x )
#-99
#21
#261
#1581
```

- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13

# 2. Question: Input three integers x, y, z, please output the three numbers from small to large.

```
l = [ ]
for i in range ( 3 ) :
p = int ( input ( ) ) # can be entered three times
l . append ( p )
l . sort ( ) # ascending order
print ( l )
```

- 1
- 2
- 3
- 4
- 5
- 6

# 3. Topic: Classical problem: There is a pair of rabbits, a pair of rabbits are born every month from the 3rd month after birth, and a pair of rabbits is born every month after the little rabbit grows to the third month. If the rabbits don’t die , what is the total number of rabbits per month?

```
f1 , f2 = 1 , 1 # Initialize (two rabbits)
for i in range ( 1 , 22 ) :
print ( "%12ld %12ld" % ( f1 , f2 ) , end = ' ' ) # Note how ld is written
if i % 3 == 0 :
print ( '' ) # Condition is met, that is, newline output
f1 += f2
f2 += f1
# 1 1 2 3 5 8
# 13 21 34 55 89 144
# 233 377 610 987 1597 2584
# 4181 6765 10946 17711 28657 46368
# 75025 121393 196418 317811 514229 832040
# 1346269 2178309 3524578 5702887 9227465 14930352
# 24157817 39088169 63245986 102334155 165580141 267914296
```

- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17

*I have shortcomings in my studies. If there are any irregularities in the code, please correct me. . .*

## Quote of the day: If you want to improve your willpower, you must recognize your weaknesses and overcome them, so that you can not be restrained by them.

# Article Directory – Extended:

For example: the use of pandas in Chapter 1 Introduction to Python Machine Learning

# foreword

For example, with the continuous development of artificial intelligence, the technology of machine learning is becoming more and more important. Many people have started learning machine learning. This article introduces the basic content of machine learning.

# 1. What is pandas?

Example: pandas is a NumPy-based tool created to solve data analysis tasks.

# 2. Use steps

## 1. Import the library

The code is as follows (example):

```
import numpy as np
import pandas as pd
import matplotlib .pyplot as plt
import seaborn as sns
import warnings
warnings . filterwarnings ( 'ignore' )
import ssl
ssl._create_default_https_context = ssl._create_unverified_context _ _ _ _
```

- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8

## 2. Read in data

The code is as follows (example):

```
data = pd.read_csv ( '
https://labfile.oss.aliyuncs.com/courses/1283/adult.data.csv ' ) print ( data.head ( ) ) _ _ _
```

- 1
- 2
- 3

The url network request data used here.

# Summarize

The above is what I will talk about today. This article not only records a few practice cases, but also briefly introduces the use of pandas, and pandas provides a large number of functions and methods that enable us to process data quickly and easily.

#### Related: python practice questions

- 1. Title description: An integer, which is a perfect square after adding 100, and a perfect square when adding 168, what is the number?
- 2. Question: Input three integers x, y, z, please output the three numbers from small to large.
- 3. Topic: Classical problem: There is a pair of rabbits, a pair of rabbits are born every month from the 3rd month after birth, and a pair of rabbits is born every month after the little rabbit grows to the third month. If the rabbits don’t die , what is the total number of rabbits per month?
- Article directory - expansion:
- foreword
- 1. What is pandas?
- 2. Use steps
- Summarize