当前位置:网站首页>[datawhale team learning] task02: mathematical operation, string and text, list
[datawhale team learning] task02: mathematical operation, string and text, list
2022-06-30 06:56:00 【weixin_ forty-three million five hundred and thirty-eight thous】
#(1)"print" Usage and “#” notes
print("hello world! come along datawhale Team up and learn !")#print Can output the contents in quotation marks ,“#” Can comment , Do not participate in program running
print('hello world!')# Quotation marks can also be single quotation marks
#(2) Mathematical operators
# plus +, To add
# minus sign -, Do subtraction
# ride *, Multiply
# except /, Do Division
# to be divisible by //, Do an integer division
# Remainder %, Take over operations
# Power operation **, Power operation
print(' Formula 5+2 be equal to ',5+2)# Add
print(' Formula 5-2 be equal to ',5-2)# Subtraction
print(' Formula 5*2 be equal to ',5*2)# Multiplication
print(' Formula 5/2 be equal to ',5/2)# division
print('7 to be divisible by 3 yes ',7//3)# to be divisible by
print('7 to be divisible by 3 The remainder is ',7%3)# Remainder
print('5 Of 2 The second power equals ',5**2)# Power operation
#< Less than no.
#> More than no.
#<= Less than or equal to sign
#>= Greater than or equal to
print(2<5)# Compare 2 And 5, Output correctly true, error false
print(5<2)
print(5>2)
print(2<=5)
print(5<=2)
print(5>=2)
#(3) String and text
cars=100
space_in_a_car=4
drivers=30
passengers=90
cars_not_driven=cars-drivers
cars_driven=drivers
carpool_capacity=cars_driven*space_in_a_car
average_passengers_per_car=passengers/cars_driven
print('There are',cars,'cars available.')
print('There are only',drivers,'drivers available.')
my_name='Hanson_Wu'
my_age=23
my_height=178#cm
my_weight=78#kg
my_eyes='black'
my_teeth='white'
my_hair='black'
print(f"Let's talk about {my_name}.")# Use double quotation marks here , Error in single quotation mark
print(f"He's {my_height}cm tall.")
print(f"He's {my_weight}kg heavy.")
print("He's so handsome.")# You can't use single quotes , To use double quotes
print(f"He's got {my_eyes} eyes and {my_hair} hair.")
print(f"His teeth are usually {my_teeth} depending on the coffee.")
total=my_age+my_height+my_weight
print(f"If I add {my_age},{my_height},and {my_weight} ,I get {total}.")
hilarious=True
joke_evaluation="Isn't that joke so funny?!{}"
print(joke_evaluation.format(hilarious))
#(4) list
# The list is python A data type in , Support for characters 、 Numbers 、 Strings and even lists ( nesting ).
# List with [] Express
list1=['ggcgyy',2022,[123,' Team learning '],'abc']
list2=[' Team learning ',215,' Happy Lantern Festival ']
print(list1)
print(list2)
# Cut of values in the list
print(list1[0]) # The first element of the output list , Left to right index default 0 Start
print(list1[-4]) # The first element of the output list , Right to left index default -1 Start
print(list2[1:3]) # The index number of the output list is 1、2 The elements of , barring 3
print(list1[1:]) # Output list page 2 To the last element
print(list2*2) # Output list 2 Time
print(list1+list2) # Output the combined list Summary :
1、SyntaxError: invalid syntax error , It's a format error , It doesn't have to be an error in the prompt , Run the entire file , Errors in the front will affect the back , So check the entire code file
2、pycharm Check for errors in : You can hover the mouse cursor over the red line on the right

Reference resources datawhale Team up to learn the tutorial :
See... For the learning tutorial 《 Zero basis to learn Python Programming thinking 》 course
【 Tutorial address 】https://linklearner.com/datawhale-homepage/index.html#/learn/detail/6
边栏推荐
猜你喜欢

Judge whether H5 is in wechat environment or enterprise wechat environment at both ends

Pay attention to this live broadcast and learn about the path to achieve the dual carbon goal of the energy industry

Google Earth Engine(GEE)——墨累全球潮汐湿地变化 v1 (1999-2019) 数据集

InnoDB engine in MySQL

1.9 - Classification of memory
![[my advanced OpenGL learning journey] about the access methods of vector and matrix classification of OpenGL shaders: xyzw/rgba/stpq and array subscripts](/img/ed/76db436ab5e35fba742dc287402fe3.png)
[my advanced OpenGL learning journey] about the access methods of vector and matrix classification of OpenGL shaders: xyzw/rgba/stpq and array subscripts

1.2(补充)

基础刷题(一)

【我的OpenGL学习进阶之旅】关于OpenGL的着色器的向量和矩阵分类的访问方式: xyzw/rgba/stpq以及数组下标

【转】存储器结构、cache、DMA架构分析
随机推荐
tomorrow! "Mobile cloud Cup" competition air publicity will start!
【Hot100】11. 盛最多水的容器
判断h5在两端是在微信环境还是企业微信环境
[my advanced OpenGL learning journey] about the access methods of vector and matrix classification of OpenGL shaders: xyzw/rgba/stpq and array subscripts
1.9 - Classification of memory
Joseph problem C language
Cluster distributed
KEIL - 下载调试出现“TRACE HW not present”
Redis cache
The 40g high-efficiency cloud disk purchased by Alibaba cloud is only 20g attached
[fuzzy neural network] mobile robot path planning based on Fuzzy Neural Network
File Transfer Protocol,FTP文件共享服务器
What underlying technologies support the metauniverse?
Deep learning --- the weight of the three good students' scores (3)
Notes: environment variables
Is Huatai stock trading safe? I want to open an account online.
Assembly language learning I (with stack co process, 32-bit registers and related instructions, to be continued 06/29)
What if I forget my account number after opening an account? Is it safe to open an account online?
How to set the hot deployment of idea web project
Graphic octet, really top