In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
Before I start this topic, I'd like to ask you: what is Python? According to Guido van Rossum, the father of Python, Python is a high-level programming language whose core design philosophy is code readability and syntax, allowing programmers to express their ideas in very little code.
For me, the number one reason for learning Python is that Python is a language that can be programmed elegantly. It can write code and implement my ideas simply and naturally.
Another reason is that we can use Python in many ways: python is really hot! It can do almost every platform in every field, including Web development, network operation and maintenance, scientific computing, 3D game development, graphical interface development, artificial intelligence and so on.
In addition to the familiar Zhihu and Douban, more and more companies have begun to use Python to quickly build website products. Accordingly, more and more companies are creating Python Web positions, so let's learn about Python.
Python Foundation
1. Variable
You can think of a variable as a word used to store values. Let's look at an example.
It is easy to define a variable in Python and assign a value to it. If you want to store the number 1 into the variable "one", let's try it:
One = 1
Isn't it super easy? You just need to assign a value of 1 to the variable "one".
Two = 2
Some_number = 10000
You can assign any value to any other variable as long as you want. As you can see from above, the variable "two" stores integer variable 2 and the variable "some_number" stores 10000.
In addition to integers, we can use Boolean values (True/Flase), strings, floating-point types, and other data types.
# booleanstrue_boolean = Truefalse_boolean = False# stringmy_name = "Leandro Tk" # floatbook_price = 15.80
two。 Control flow: conditional statement
"If" uses an expression to determine whether a statement is True or False, and if it is True, executes the code in if, as shown in the following example:
If True:
Print ("Hello Python If") if 2 > 1:
Print ("2 is greater than 1")
2 is larger than 1, so the print code is executed.
When the expression in "if" is false, the "else" statement will be executed.
If 1 > 2:
Print ("1 is greater than 2") else:
Print ("1 is not greater than 2")
1 is smaller than 2, so the code in "else" executes.
You can also use the "elif" statement:
If 1 > 2:
Print ("1 is greater than 2") elif 2 > 1:
Print ("1 is not greater than 2") else:
Print ("1 is equal to 2")
3. Loop and iteration
In Python, we can iterate in different forms. I'll talk about while and for.
While loop: when the statement is True, the code block inside the while executes. So the following code will print out 1 to 10.
Num = 1while num
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.