当前位置:网站首页>[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
边栏推荐
- Go installation and configuration (1)
- 阿里云买的40G高效云盘挂载只有20G
- tomorrow! "Mobile cloud Cup" competition air publicity will start!
- 1.3 - Code System
- Records of problems solved (continuously updated)
- Getting started with research
- What underlying technologies support the metauniverse?
- Use of sscanf function
- 【Hot100】15. 三数之和
- freemarker
猜你喜欢

Fastapi learning Day1

First line of code (Third Edition) learning notes

ETL为什么经常变成ELT甚至LET?

Principle: webmvcconfigurer and webmvcconfigurationsupport pit avoidance Guide
![[Hot100]回文子串 与 最长回文子串](/img/a5/10dec640f02023c4d55cb42e6309fb.png)
[Hot100]回文子串 与 最长回文子串

SOC_ SD_ CLK

Xshell传输文件

ROS system problem: rosdep init

Assembly language learning I (with stack co process, 32-bit registers and related instructions, to be continued 06/29)

1.2(补充)
随机推荐
Relevant database questions.
CPU到底是怎么识别代码的?
1.2 (supplementary)
Basic fragmentary thoughts
与MQTT的初定情缘
Google Earth engine (GEE) - Murray global tidal wetland change V1 (1999-2019) data set
Practice summary of Prometheus project in amu Laboratory
Ls1028 manual
Joseph problem C language
6、 Shopping ⻋ and orders
RT thread application
【每日一题】535. TinyURL 的加密与解密
1.8 - multi level storage
【Mask-RCNN】基于Mask-RCNN的目标检测和识别
银河麒麟初体验
How does the CPU recognize the code?
Browser downloads files as attachments
High performance distributed execution framework ray
leetcode:98. 验证二叉搜索树
1.3 - Code System