current position：Home>Chapter 1: introduction to Python programming-4 Hello World
Chapter 1: introduction to Python programming-4 Hello World
2022-01-30 05:36:22 【Small horn】
Python Hello World
The goal is
In this article , You will learn how to use Python Develop the first program “Hello, World!”.
Create a new Python project
First , Create a file called helloworld New folder for .
second , start-up VS Code and open helloworld Folder .
Third , Create a new app.py file , Enter the following code and save the file :
print('Hello,World!') Copy code
print() Is a built-in function , Used to display messages on the screen . In this case , It will display messages “
What is a function
When you add two numbers , This is a function . When you multiply two numbers , It's also a function .
Each function accepts your input , Apply some rules , And return a result .
In the example above ,
print() It's a function . It accepts a string and displays it on the screen .
Python There are many built-in functions , Such as
print() function , So you can use them out of the box .
Besides ,Python Allows you to define functions , Later you will learn how to do this .
perform Python Hello World Program
To execute app.py file , First, in the Windows or macOS or Linux Start the command prompt on .
then , Navigate to helloworld Folder .
then , Enter the following command to execute app.py file :
python app.py Copy code
If everything goes well , You will see the following message on the screen :
Hello,World! Copy code
If you use VS Code, You can also start by VS Code Terminal in :
- Enter menu “Terminal>New Terminal”
- Or use keyboard shortcuts Ctrl+Shift+`.
Usually , Backquote key (`) Located on the keyboard Esc Under key .
Python IDLE yes Python By default, the distribution comes with Python Integrated development environment (IDE).
Python IDLE Also known as interactive interpreter . It has many characteristics , Such as :
- Use syntax highlighting for code editing
- Smart indent
- And autocomplete
In short ,Python IDLE Help you experiment quickly by trial and error Python.
Next, step by step, I'll show you how to start Python IDLE And use it to perform Python Code :
First , start-up Python IDLE Program :
A new Python Shell The window will display as follows :
Now? , You can use the cursor
>>> After input Python Code , And press
Enter Key to execute it .
for example , You can enter the code print('Hello, World!'), Then press Enter key , You'll see Hello, World! Immediately appear on the screen :
- stay Windows or macOS or Linux Used in terminals on
python Path to file .pyCommand to execute
Path to file .pyfile .
print()Function displays a message on the screen .
- Use Python IDLE Input Python Code and execute immediately .
author[Small horn],Please bring the original link to reprint, thank you.
The sidebar is recommended
- Python collects and monitors system data -- psutil
- Python chat room (Tkinter writing interface, streaming, socket to realize private chat, group chat, check chat records, Mysql to store data)
- Learning this Python library can reduce at least 100 lines of code
- leetcode 67. Add Binary（python）
- Regular re parameter replacement of Python 3 interface automation test framework
- V. pandas based on Python
- Only 15 lines of code is needed for face detection! (using Python and openCV)
- [Python crawler Sao operation] you can crawl Sirius cinema movies without paying
- leetcode 69. Sqrt(x)（python）
- Teach you to read the source code of Cpython (I)
guess what you like
Snowball learning started in the fourth quarter of Python. One needs three meals. I have a new understanding of Python functional programming, process-oriented, object-oriented and functional
leetcode 88. Merge Sorted Array（python）
Don't you know more about a python library before the end of 2021?
Python crawler web page parsing artifact XPath quick start teaching!!!
Use Python and OpenCV to watermark the image
String and related methods of Python data type introduction
Heapq module of Python module
Introduction to beautiful soup of Python crawler weapon, detailed explanation, actual combat summary!!!
Event loop of Python collaboration series
Django docking pin login system
- [recalling the 1970s] using Python to repair the wonderful memories of parents' generation, black-and-white photos become color photos
- You used to know Python advanced
- Pyinstaller package Python project
- 2021 IEEE programming language rankings: Python tops the list!
- Implementation of Python automatic test control
- Python advanced: [Baidu translation reverse] graphic and video teaching!!!
- Do you know the fuzzy semantics in Python syntax?
- [Python from introduction to mastery] (XXVII) learn more about pilot!
- Playing excel office automation with Python
- Some applications of heapq module of Python module
- Python and go languages are so popular, which is more suitable for you?
- Python practical skills task segmentation
- Python simulated Login, numpy module, python simulated epidemic spread
- Python opencv contour discovery function based on image edge extraction
- Application of Hoff circle detection in Python opencv
- Python reptile test ox knife (I)
- Day 1: learn the Django framework of Python development
- django -- minio_ S3 file storage service
- [algorithm learning] 02.03 Delete intermediate nodes (Java / C / C + + / Python / go)
- Similarities and differences of five pandas combinatorial functions
- Learning in Python + opencv -- extracting corners
- Python beginner's eighth day ()
- Necessary knowledge of Python: take you to learn regular expressions from zero
- Get your girlfriend's chat records with Python and solve the paranoia with one move
- My new book "Python 3 web crawler development practice (Second Edition)" has been recommended by the father of Python!
- From zero to familiarity, it will take you to master the use of Python len() function
- Python type hint type annotation guide
- leetcode 108. Convert Sorted Array to Binary Search Tree（python）
- For the geometric transformation of Python OpenCV image, let's first talk about the extraordinary resize function
- leetcode 701. Insert into a Binary Search Tree （python）
- For another 3 days, I sorted out 80 Python datetime examples, which must be collected!
- Python crawler actual combat | using multithreading to crawl lol HD Wallpaper
- Complete a python game in 28 minutes, "customer service play over the president card"
- The universal Python praise machine (commonly known as the brushing machine) in the whole network. Do you want to know the principle? After reading this article, you can write one yourself
- How does Python compare file differences between two paths
- Common OS operations for Python
- [Python data structure series] linear table - explanation of knowledge points + code implementation
- How Python parses web pages using BS4
- How do Python Network requests pass parameters
- Python core programming - decorator