Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to write a hello world program with python

Shulou Source: shulou.com Published: 2022-06-01 17:54:11 10月22日 Update

How to write a hello world program in python, for this problem, this article describes the corresponding analysis and solution in detail, hoping to help more small partners who want to solve this problem find a simpler and easier way.

(1)Create a Hello.py

[hadoop@slave1 desktop]$ vi hello.py

Click here to fold or open

print("Hello World! ")

(2)Run python script with "python *.py"

[hadoop@slave1 desktop]$ python hello.py

Hello World!

Or:

Click here to fold or open

$ python

Python 2.6.6 (r266:84292, Feb 21 2013, 23:54:59)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> print "hello world"

hello world

(3)accept user input

[hadoop@slave1 desktop]$ vi hello.py

Click here to fold or open

print("Hello World! ")

x=input("x:")

y=input("y:")

print(x*y)

print("I will begin to learn python,come on ! ")

(4)implementation

[hadoop@slave1 desktop]$ python hello.py

Hello World!

x:125

y:2

250

I will begin to learn python,come on !

About how to use python to write a hello world program questions to share the answer here, I hope the above content can be of some help to everyone, if you still have a lot of doubts not solved, you can pay attention to the industry information channel to learn more related knowledge.

Tags: Desktops questions programs more help answers easy easy content guys partners methods users knowledge articles scripts industry information information channels channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Redmi macOS MySQL vpn