How to build python scripts in Visual Studio Code

Python is a high-level, interpreted language with a simple, easy-to-learn syntax. It is a powerful language that is widely used in various fields, including web development, data analysis, and scientific computing.

Getting Started

To start using Python, you will need to install it on your computer. You can download the latest version of Python from the official website (

Once you have installed Python, you can start using it in a few different ways:

  • Using the interactive interpreter: You can open the Python interpreter by typing “python” in the command prompt (on Windows) or terminal (on macOS and Linux). This allows you to type Python commands and see their results immediately.

  • Writing scripts: You can create a Python script by creating a text file with a .py extension and writing Python code in it. You can then run the script by typing “python” in the command prompt or terminal.

  • Using an integrated development environment (IDE): An IDE is a specialized software that provides a more advanced interface for writing, debugging, and running code. Some popular Python IDEs include Visual Studio Code, PyCharm, Spyder, and IDLE.

Step by step guide for Visual Studio Code

  1. Install Visual Studio Code 
  2. Install Python latest release
  3. In VS Code install the python extensions
    In VS Code install the python extensions

  4. Create a new folder and inside create a file with extension py. To run the python file just click the play button from up right window , and the result is visible in Terminal window bellow.
create a file with extension py

 Basic Syntax

Here are some basic syntax rules for Python:

  • Python is case-sensitive, which means that variables, function names, and keywords must be spelled correctly.

  • Python uses indentation to denote blocks of code. You should use four spaces (or one tab) to indent your code.

  • Python uses the # symbol to start a comment. Everything after a # on a line is ignored by the interpreter.

  • You can use the print() function to output text to the console. You can pass a string or a variable to the print() function.


    In Python, you can use variables to store values. You can create a variable by assigning a value to it using the = operator.

     Data Types

    Python has several built-in data types, including:

    • int: integer values (e.g. 1, 2, 3)
    • float: floating-point values (e.g. 1.5, 3.14)
    • str: string values (e.g. “hello”, “world”)
    • bool: boolean values (True or False)

        You can use the type() function to check the data type of a value.

<br /># This is a comment<br /><br /># Assign a value to a variable<br />x = 5<br /><br /># You can also assign multiple variables at once<br />i, x, y, z = 1, 1.3, 2, 0<br /><br /># You can use variables in expressions<br />a = x + y<br /><br /># You can also use variables in print statements<br />print(a)<br />i = 234<br />print(type(i))  # Output: <class int=""><br /><br />x = 5.456<br />print(type(x))  # Output: <class float=""><br /><br />y = "hello"<br />print(type(y))  # Output: <class str=""><br /><br />z = True<br />print(type(z))  # Output: <class bool=""><br /><br /># Output a string<br />print("Hello, world!")<br /><br /># Output a variable<br />name = "Alice"<br />print(name)<br />



Here are some basic Python instructions that you should be familiar with:

  • print(): Outputs text or the value of a variable to the console.

  • input(): Reads input from the user and stores it as a string.

  • if: Performs a block of code if a condition is True.

  • for: Iterates over a sequence (such as a list or string) and performs a block of code for each element.

  • while: Repeats a block of code while a condition is True.

  • def: Defines a function.

  • return: Exits a function and returns a value.


    # Output text to the console <br />print("Hello, world!")<br /><br /># Read input from the user<br />name = input("Enter your name: ")<br /><br /># Use an if statement to check a condition<br />if name == "Alice":<br />  print("Hi, Alice!")<br />else:<br />  print("Hello, stranger!")<br /><br /># Use a for loop to iterate over a list<br />for i in range(5):<br />  print(i)<br /><br /># Use a while loop to repeat a block of code<br />i = 0<br />while i < 5:<br />  print(i)<br />  i += 1<br /><br /># Define a function<br />def greet(name):<br />  return "Hello, " + name<br /><br /># Call the function<br />greeting = greet(name)<br />print(greeting)<br />


De Florin Simedru


Lasă un răspuns

Adresa ta de email nu va fi publicată. Câmpurile obligatorii sunt marcate cu *

The reCAPTCHA verification period has expired. Please reload the page.