Home
Forums
New posts
Search forums
What's new
New posts
New resources
New profile posts
Latest activity
Resources
Latest reviews
Search resources
Members
Current visitors
New profile posts
Search profile posts
DMCA Policy
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
FEEL FREE TO SHARE TUTORIALS, YOUR SKILS & KNOWLEDGE ON CODING, SCRIPTS, THEMES, PLUGINS OR ANY RESOURCES YOU HAVE WITH THE COMMUNITY-
Click Here To Post Your Request,
JOIN COMPUTER REPAIR FORUM
Home
Forums
WEB DEVELOPMENT CODING
Python
How to write your first program in Python
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="webguru" data-source="post: 7" data-attributes="member: 3"><p><span style="font-size: 20px">How to Get Started With Python?</span></p><p>In this tutorial, you will learn to install and run Python on your computer. Once we do that, we will also write our first Python program.</p><p></p><p>Python is a cross-platform programming language, which means that it can run on multiple platforms like Windows, macOS, Linux, and has even been ported to the Java and .NET virtual machines. It is free and open-source.</p><p>Even though most of today's Linux and Mac have Python pre-installed in it, the version might be out-of-date. So, it is always a good idea to install the most current version.</p><hr /><h3>The Easiest Way to Run Python</h3><p>The easiest way to run Python is by using <strong>Thonny IDE</strong>.</p><p>The Thonny IDE comes with the latest version of Python bundled in it. So you don't have to install Python separately.</p><p>Follow the following steps to run Python on your computer.</p><ol> <li data-xf-list-type="ol">Download <a href="https://thonny.org/" target="_blank">Thonny IDE</a>.</li> <li data-xf-list-type="ol">Run the installer to install <strong>Thonny</strong> on your computer.</li> <li data-xf-list-type="ol">Go to: <strong>File</strong> > <strong>New</strong>. Then save the file with .py extension. For example, hello.py, example.py, etc.<br /> You can give any name to the file. However, the file name should end with <strong>.py</strong></li> <li data-xf-list-type="ol">Write Python code in the file and save it.<img src="https://cdn.programiz.com/sites/tutorial2program/files/test.jpg" alt="Run Python on your computer" class="fr-fic fr-dii fr-draggable " style="" />Running Python using Thonny IDE</li> <li data-xf-list-type="ol">Then Go to <strong>Run</strong> > <strong>Run current script</strong> or simply click <strong>F5</strong> to run it.</li> </ol><hr /><h3>Install Python Separately</h3><p>If you don't want to use Thonny, here's how you can install and run Python on your computer.</p><ol> <li data-xf-list-type="ol">Download the <a href="https://www.python.org/downloads/" target="_blank">latest version of Python</a>.</li> <li data-xf-list-type="ol">Run the installer file and follow the steps to install Python<br /> During the install process, check <strong>Add Python to environment variables</strong>. This will add Python to environment variables, and you can run Python from any part of the computer.<br /> <br /> Also, you can choose the path where Python is installed.<img src="https://cdn.programiz.com/sites/tutorial2program/files/python-install_0.jpg" alt="Install Python on your computer" class="fr-fic fr-dii fr-draggable " style="" />Installing Python on the computer</li> </ol><p>Once you finish the installation process, you can run Python.</p><hr /><h4>1. Run Python in Immediate mode</h4><p></p><p></p><p></p><p>Once Python is installed, typing python in the command line will invoke the interpreter in immediate mode. We can directly type in Python code, and press Enter to get the output.</p><p>Try typing in 1 + 1 and press enter. We get 2 as the output. This prompt can be used as a calculator. To exit this mode, type quit() and press enter.</p><p><img src="https://cdn.programiz.com/sites/tutorial2program/files/python-run-command-mode.jpg" alt="Run Python in Immediate mode" class="fr-fic fr-dii fr-draggable " style="" />Running Python on the Command Line</p><hr /><h4>2. Run Python in the Integrated Development Environment (IDE)</h4><p>We can use any text editing software to write a Python script file.</p><p>We just need to save it with the .py extension. But using an IDE can make our life a lot easier. IDE is a piece of software that provides useful features like code hinting, syntax highlighting and checking, file explorers, etc. to the programmer for application development.</p><p>By the way, when you install Python, an IDE named <strong>IDLE</strong> is also installed. You can use it to run Python on your computer. It's a decent IDE for beginners.</p><p>When you open IDLE, an interactive Python Shell is opened.</p><p><img src="https://cdn.programiz.com/sites/tutorial2program/files/idle-python.jpg" alt="Python IDLE" class="fr-fic fr-dii fr-draggable " style="" />Python IDLE</p><p>Now you can create a new file and save it with <strong>.py</strong> extension. For example, <strong>hello.py</strong></p><p>Write Python code in the file and save it. To run the file, go to <strong>Run</strong> > <strong>Run Module</strong> or simply click <strong>F5</strong>.</p><p><img src="https://cdn.programiz.com/sites/tutorial2program/files/python-program-run-idle.jpg" alt="Run Python programs in IDLE" class="fr-fic fr-dii fr-draggable " style="" />Running a Python program in IDLE</p><hr /><h3>Your first Python Program</h3><p>Now that we have Python up and running, we can write our first Python program.</p><p>Let's create a very simple program called Hello World. A <strong>"Hello, World!"</strong> is a simple program that outputs Hello, World! on the screen. Since it's a very simple program, it's often used to introduce a new programming language to beginners.</p><p>Type the following code in any text editor or an IDE and save it as hello_world.py</p><p></p><p>print("Hello, world!")</p><p><a href="https://www.programiz.com/python-programming/online-compiler" target="_blank">Run Code</a></p><p>Then, run the file. You will get the following output.</p><p>Hello, world!</p><p>Congratulations! You just wrote your first program in Python.</p><p>As you can see, this was a pretty easy task. This is the beauty of the Python programming language</p></blockquote><p></p>
[QUOTE="webguru, post: 7, member: 3"] [SIZE=20px]How to Get Started With Python?[/SIZE] In this tutorial, you will learn to install and run Python on your computer. Once we do that, we will also write our first Python program. Python is a cross-platform programming language, which means that it can run on multiple platforms like Windows, macOS, Linux, and has even been ported to the Java and .NET virtual machines. It is free and open-source. Even though most of today's Linux and Mac have Python pre-installed in it, the version might be out-of-date. So, it is always a good idea to install the most current version. [HR][/HR] [HEADING=2]The Easiest Way to Run Python[/HEADING] The easiest way to run Python is by using [B]Thonny IDE[/B]. The Thonny IDE comes with the latest version of Python bundled in it. So you don't have to install Python separately. Follow the following steps to run Python on your computer. [LIST=1] [*]Download [URL='https://thonny.org/']Thonny IDE[/URL]. [*]Run the installer to install [B]Thonny[/B] on your computer. [*]Go to: [B]File[/B] > [B]New[/B]. Then save the file with .py extension. For example, hello.py, example.py, etc. You can give any name to the file. However, the file name should end with [B].py[/B] [*]Write Python code in the file and save it.[IMG alt="Run Python on your computer"]https://cdn.programiz.com/sites/tutorial2program/files/test.jpg[/IMG]Running Python using Thonny IDE [*]Then Go to [B]Run[/B] > [B]Run current script[/B] or simply click [B]F5[/B] to run it. [/LIST] [HR][/HR] [HEADING=2]Install Python Separately[/HEADING] If you don't want to use Thonny, here's how you can install and run Python on your computer. [LIST=1] [*]Download the [URL='https://www.python.org/downloads/']latest version of Python[/URL]. [*]Run the installer file and follow the steps to install Python During the install process, check [B]Add Python to environment variables[/B]. This will add Python to environment variables, and you can run Python from any part of the computer. Also, you can choose the path where Python is installed.[IMG alt="Install Python on your computer"]https://cdn.programiz.com/sites/tutorial2program/files/python-install_0.jpg[/IMG]Installing Python on the computer [/LIST] Once you finish the installation process, you can run Python. [HR][/HR] [HEADING=3]1. Run Python in Immediate mode[/HEADING] Once Python is installed, typing python in the command line will invoke the interpreter in immediate mode. We can directly type in Python code, and press Enter to get the output. Try typing in 1 + 1 and press enter. We get 2 as the output. This prompt can be used as a calculator. To exit this mode, type quit() and press enter. [IMG alt="Run Python in Immediate mode"]https://cdn.programiz.com/sites/tutorial2program/files/python-run-command-mode.jpg[/IMG]Running Python on the Command Line [HR][/HR] [HEADING=3]2. Run Python in the Integrated Development Environment (IDE)[/HEADING] We can use any text editing software to write a Python script file. We just need to save it with the .py extension. But using an IDE can make our life a lot easier. IDE is a piece of software that provides useful features like code hinting, syntax highlighting and checking, file explorers, etc. to the programmer for application development. By the way, when you install Python, an IDE named [B]IDLE[/B] is also installed. You can use it to run Python on your computer. It's a decent IDE for beginners. When you open IDLE, an interactive Python Shell is opened. [IMG alt="Python IDLE"]https://cdn.programiz.com/sites/tutorial2program/files/idle-python.jpg[/IMG]Python IDLE Now you can create a new file and save it with [B].py[/B] extension. For example, [B]hello.py[/B] Write Python code in the file and save it. To run the file, go to [B]Run[/B] > [B]Run Module[/B] or simply click [B]F5[/B]. [IMG alt="Run Python programs in IDLE"]https://cdn.programiz.com/sites/tutorial2program/files/python-program-run-idle.jpg[/IMG]Running a Python program in IDLE [HR][/HR] [HEADING=2]Your first Python Program[/HEADING] Now that we have Python up and running, we can write our first Python program. Let's create a very simple program called Hello World. A [B]"Hello, World!"[/B] is a simple program that outputs Hello, World! on the screen. Since it's a very simple program, it's often used to introduce a new programming language to beginners. Type the following code in any text editor or an IDE and save it as hello_world.py print("Hello, world!") [URL='https://www.programiz.com/python-programming/online-compiler']Run Code[/URL] Then, run the file. You will get the following output. Hello, world! Congratulations! You just wrote your first program in Python. As you can see, this was a pretty easy task. This is the beauty of the Python programming language [/QUOTE]
Insert quotes…
Verification
Post reply
Richest Freecoded User
Most Freecoin
freecoded
4,876 Freecoin
J
Johnhendrick
645 Freecoin
S
Smith16
607 Freecoin
Davy200
590 Freecoin
nathan69
426 Freecoin
Laureine
415 Freecoin
A
anajeen
395 Freecoin
P
Peterparker87
331 Freecoin
C
codeguru
282 Freecoin
Tekera
267 Freecoin
Home
Forums
WEB DEVELOPMENT CODING
Python
How to write your first program in Python
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top