当前位置:网站首页>Small test (I)
Small test (I)
2022-07-26 03:07:00 【Programmer Haozi】
Catalog
The main points of this issue :
The main points of this issue :
We have learned a lot in previous issues , In this issue, let's examine , Here I have prepared three small questions , As long as you look carefully in front, you can make it , Try the current screen !!!
The content of this issue :
The first question is :
subject : It's today 2022 year 7 month 25 Japan , Then we write it as a time integer, which is :2022725, Here we need to calculate its year separately 、 month 、 Japan
Ideas : stress the essentials :2022725 Using calculation , So what is calculation ? That's addition 、 Subtraction 、 Multiplication 、 division 、 to be divisible by 、 Take several of them to write this question
I believe you must have your own answer , Then let's solve it :
Source code :
Date = 2022725
Year = Date // 1000 # Get by divising 2022
Month = Date // 100 %10 # Get by dividing and remainder 7
Day = Date % 100 # Get... By taking the remainder 25
# Print the results :
print(Year)
print(Month)
print(Day)Print the results :

The second question is :
subject : take Hello、Python These two words are spliced together .
Ideas : Still focus on key points :“ word ” It is determined that this is a string type “ Splicing ” That is, put them together therefore : The test point of this question is the splicing of strings .
I believe you must have your own answer , Then let's solve it :
Source code :
str1 = 'Hello' # First assign the first value
str2 = 'Python' # Assign the second value
# The first one is :
# String formatting splicing
print('%s %s' % (str1,str2))
# The second kind :
# join Method splicing
print(' '.join([str1,str2]))
# The third kind of :
# format Method splicing
print('{} {}'.format(str1,str2))
# A fourth :
# format Abbreviation splicing
print(f'{str1} {str2}')Print the results :

Third question :
subject : Let the user provide the radius , Then calculate the circumference and area of the corresponding circle ( Keep two decimal places at the end )
Ideas : Focus on the key points : The user provides , Use our input Built in functions And it needs the help of mathematical modules to obtain the PI Understand the formula of circle circumference and area Keep two decimal places , You can use string formatting and high-precision modules
I believe you must have your own answer , Then let's solve it :
Source code :
# Import math module
import math
# Import high-precision modules
import decimal
# Let the user provide the radius of the circle
r = int(input(" Please enter the radius of the circle :"))
# Get the pi
pi = math.pi
# The perimeter formula ( High precision )
C = decimal.Decimal(r) * decimal.Decimal(2) * decimal.Decimal(pi)
# Area formula ( High precision )
S = decimal.Decimal(r) ** decimal.Decimal(2) * decimal.Decimal(pi)
# Print the perimeter with two decimal places
print('%.2f' % C)
# Print the area with two decimal places
print('%.2f' % S)Print the results ( Take the radius as 5 To test ):

Summary :
In this issue, we practiced three small problems , I hope I can help you !!!
边栏推荐
- canvas——心电图的设计,以及如何清理画布
- OxyCon 2022 网络抓取前沿大会即将开启!
- [steering wheel] use the 60 + shortcut keys of idea to share with you, in order to improve efficiency (reconstruction)
- After clicking play, the variables in editorwindow will be destroyed inexplicably
- JVM内存模型解析
- Nahamcon CTF 2022 babyrev reverse analysis
- Jsd-2204-cool shark Mall (Management Commodity module) -day02
- LeetCode·每日一题·919.完全二叉树插入器·层次遍历·BFS
- [translation] safety. Value of sboms
- ENVI_ Idl: create HDF5 file and write data (take writing GeoTIFF file to HDF file as an example) + detailed parsing
猜你喜欢

ES6 set and map
![[C Advanced] deeply explore the storage of data (in-depth analysis + interpretation of typical examples)](/img/1e/33f9cc9446dcad8cdb78babbb5a22c.jpg)
[C Advanced] deeply explore the storage of data (in-depth analysis + interpretation of typical examples)

Be highly vigilant! Weaponization of smartphone location data on the battlefield

snownlp库各功能及用法

如何正确计算 Kubernetes 容器 CPU 使用率

Swin Transformer【Backbone】

朋友刚学完自动化测试就拿25Koffer,我功能测试何时才能到头?

Cloud native guide what is cloud native infrastructure

Difference between soft link and hard link

重装Win7系统如何进行?
随机推荐
From the annual reports of major apps, we can see that user portraits - labels know you better than you do
Extended Physics-InformedNeural Networks论文详解
Three years of software testing experience, salary has been stuck at 10K, how to improve and develop automated testing?
(九)属性自省
朋友刚学完自动化测试就拿25Koffer,我功能测试何时才能到头?
Cycle and branch (I)
Swin Transformer【Backbone】
Anti electronic ink screen st7302
Opencv报错:(parameter or structure field))Unrecognized or unsupported array type in functon ‘cvGetMat‘
GoLang 抽奖系统 设计
【无标题】
Golang log programming system
[translation] cloud like internal load balancer for kubernetes?
经典面试问题——OOP语言的三大特征
Chen Yili, China Academy of communications technology: cost reduction and efficiency increase are the greatest value of Enterprise Cloud native applications
MySQL教程:MySQL数据库学习宝典(从入门到精通)
An article allows you to understand the relevance of cloud native containerization
How to close the case prompt icon of win11? Closing method of win11 case prompt Icon
[translation] announce Vites 13
Hello World driver (II) - primary version