In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what type is Python". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what type is Python".
Brief introduction
When developers start to use artificial intelligence (AI) and machine learning (ML) software, the programming languages they are most likely to encounter today are Python and Cmax Clearing +. In most cases, CCompact + is used for specialized applications, such as embedded Internet of things (IoT) and highly optimized, hardware-specific neural network libraries.
Python is the most commonly used language in most AI and ML application development, even for prototyping and optimizing models for those IoT and hardware-accelerated applications.
For developers who start using Python in other languages such as C #, Java, and even JavaScript, this article introduces you to the key elements of Python's unique syntax, such as loops, and how they differ from what you might know.
Other articles in this series will explore how to use the many Python libraries available to AI and ML developers, such as OpenCV, Natural Language Toolkit (NLTK), Keras, and TensorFlow.
Where to get Python
The first question that developers usually ask is: where do I get Python?
The answer is: it depends on your system and programming environment. By default, Python is installed on Mac OS and some Linux distributions. For systems without Python, you can obtain the installer from the following location:
On the download page of Python
In the Microsoft Store
Package management system, including apt-get, rpm, homebrew, etc.
Another option is Jupyter Notebooks and JupyterLabs interactive development tools.
The third option-- the choice we recommend and will use for these Python AI/ML articles-- is Anaconda, a comprehensive software platform designed for statistics, data science and AI/ML projects.
Anaconda includes JupyterLab (the Web-based IDE mentioned earlier) as well as many other tools, libraries, and sample data sources that you may need when learning AI. Once we understand machine learning libraries, datasets, and visualization, you will find them very helpful.
Which version: Python 2 or Python 3?
For language novices, using Python 2 or Python 3 is a common source of confusion.
Python 2 is an old version that is still used frequently and is still installed in some current operating systems as the default version of Python. Official support for Python 2 will end in early 2020.
If you are new to using Python, you should use Python 3.
Ongoing support and development of Python 3 continues. This also applies to libraries you may want to use: some may still support both versions, but many will move completely to Python 3 or may do so.
How do you know which version is installed on your system?
On Linux systems and Mac OS, the python command defaults to Python 2, and you can use the python3 command with Python 3.
To determine which version is installed on the system, go to the terminal window or command prompt and run the following command:
Python-version
If Python is installed, it returns the version of Python used by the python command.
Python 2.7.16
The python3-- version command does the same for Python 3.
Python 3.7.4 identifies the Python version in the code example
Online tutorials do not always explicitly mention whether they use Python 2 or Python 3. Fortunately, you can use some heuristic methods to determine the version of the tutorial.
First, there are different ways to print text on standard output. In Python 3, there is only one effective way to do this:
# Python 2 and Python This is a comment, by the wayprint ("Hello, world!")
This syntax is also valid in Python 2, but this alternative syntax is more commonly used in Python 2 examples:
# This only works in Python 2print "Hello, world!" Python language fundamentals: types and variables
Python is a dynamic type. The type is not associated with the variable name, only with the variable value. This is different from statically typed languages such as C # and Java, where you cannot write I = "test"; if you define int I = 0 test later. In Python, you can.
Python is strongly typed (for example, JavaScript is weakly typed). In strongly typed languages, there are stricter restrictions on operations between different types of values. In JavaScript, you can execute "abc" + 1 and end "abc1" with string, but if you try the same operation in Python, you will receive an error indicating that you cannot concatenate a string with an integer.
Assigning variables in Python can be done like this:
Name = "value"
Note that the line does not end with a semicolon.
The definition and call function is as follows:
Def say_hello (who): print ("Hello", who) name = input ("Your name:") say_hello (name)
Unlike languages such as C #, Python does not use square brackets to specify which lines of code belong to functions. Instead, Python uses indentation. A series of lines with the same indentation level form a block. The recommended way to indent code is to use four spaces per indentation level. However, you can also use tabs or other numbers of spaces. Indentation only needs to be consistent within the block.
You can use the return keyword to return a value from the function:
Def sum (a, b): return a + b
If the function does not have a return statement, it returns None (Python's null).
Python also supports higher-order functions (functions that return functions or take functions as arguments). For example, the operation function returns one of two functions:
Def sum (a, b): return a + bdef difference (a, b): return a-bdef operation (calculate_sum): if calculate_sum: return sum else: return difference
You can then use:
Operation (True) (5,4) Thank you for your reading, the above is the content of "what type of Python", after the study of this article, I believe you have a deeper understanding of what type of Python is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.