DEV Community

Tina Popli
Tina Popli

Posted on

Python for Beginners - Part 1

Link for Introduction: https://dev.to/tina_popli/python-for-beginners-introduction-1pa2

In the earlier section, we touched upon the fundamentals of Python, exploring why it is regarded as a beginner-friendly language and how it makes an easy entry into programming.

Once you look into a python code, the immediate understanding is often the exact logic the developer has put into it. This simplicity contributes to a clear understanding of the language and its syntax, making it accessible for beginners and those new to programming.

INSTALLATION STEPS

1) To download/install Python, click on this link-https://www.python.org/downloads/ and choose the latest/desired version.

2) Once installed, install the IDE, You can use any ide, the below example shows PyCharm. https://www.jetbrains.com/pycharm/download/?section=windows

IDE is an integrated development environment (IDE).
It is a software that combines all the developer tools into a single graphical user interface (GUI).

Basic Syntax of Python

1. #Program to display "Hello, World"
2.print("Hello, World")

Enter fullscreen mode Exit fullscreen mode
  1. # in python means the corresponding line is a comment.
    A comment in a programming language means that it is not a part of the execution. It is used for you or someone else to understand what the code/logic means.

  2. print is a keyword in python which refers to display.
    The string inside the bracket/parenthesis: Hello,World will be printed. Basically, anything we input inside the parenthesis after print, will be displayed. As this is inside " " it will by default take the whole string and display the content inside "". Note that it doesn't include " " while displaying.

What if we want to take input from the User?

We use another built-in keyword : input
Let's see how!

1.#Program that takes input from the User
2.fav_lang= input("What is your favourite language?")
3.print(fav_lang)
Enter fullscreen mode Exit fullscreen mode

Let's break it down step by step and understand what this mean!

  1. As mentioned earlier, this is a comment, so it does not execute.
  2. fav_lang is nothing but a variable which basically stores the value which the user inputs. When we use input("What is your favourite language?" we are basically printing What is your favourite language? while waiting for the user to input their value respectively. 3.Let's output the value stored in fav_lang.

Note: If you are copying this snippet, please omit the line numbers, as they are provided for your reference. After providing your input, press enter when prompted.

What happens when we run the above code?
Code this in your desired IDE (Python must be installed in your system) and comment the output you get! :)
You can also use the command prompt and type, python and start typing your code.

Top comments (0)