Top 10 Programming Language to learn in 2023

Are you a programming enthusiast looking to stay ahead of the curve in 2023? With the ever-evolving tech landscape, keeping up with the Best Programming Language to learn can be a daunting task. Fear not, as we have compiled a list of the top 10 Programming Languages that you should consider learning in 2023. Python: This versatile language continues to dominate in 2023, with its ease of use, readability, and a vast library of modules. JavaScript: As web development grows increasingly popular, JavaScript remains a crucial player, with its ability to create dynamic and interactive web pages. Java: This language has stood the test of time and remains a popular choice for enterprise software development. C++: A staple in the gaming and systems development industries, C++ offers exceptional performance and memory management. Swift: Apple's preferred language for iOS app development, Swift continues to grow in popularity with its simplicity and reliability. R: As data science and machin

Scope Variables and Return Statement in Python | Python Theory

Scope of Variables

All variables in a program may not be accessible at all locations in that program. This depends on where you have declared a variable.

The scope of a variable determines the portion of the program where you can access a particular identifier. There are two basic scopes of variables in Python −

  • Global variables
  • Local variables

Global vs. Local variables

Variables that are defined inside a function body has a local scope, and those defined outside have a global scope.

This means that local variables can be accessed only inside the function in which they are declared, whereas global variables can be accessed throughout the program body by all functions. When you call a function, the variables declared inside it are brought into scope. Following is a simple example −

total = 0; # This is global variable.

# Function definition is here

    def sum( arg1, arg2 ):

# Add both the parameters and return them."

    total = arg1 + arg2; # Here total is local variable.

    print "Inside the function local total : ", total

    return total;

# Now you can call sum function

    sum( 10, 20 );

    print "Outside the function global total: ", total

When the above code is executed, it produces the following result −

Inside the function local total: 30

Outside the function global total :  0


The return statement

The return statement is used to exit a function and go back to the place from where it was called.The statement return [expression] exits a function, optionally passing back an expression to the caller. A return statement with no arguments is the same as return None.

Syntax of return

    return [expression_list]

This statement can contain an expression which gets evaluated and the value is returned. If there is no expression in the statement or the return statement itself is not present inside a function, then the function will return the None object.

For example:-

All the above examples are not returning any value. You can return a value from a function as follows −

# Function definition is here

    def sum( arg1, arg2 ):

# Add both the parameters and return them."

    total = arg1 + arg2

    print "Inside the function : ", total

    return total;

# Now you can call sum function

    total = sum( 10, 20 );

    print "Outside the function : ", total

    When the above code is executed, it produces the following result −

    Inside the function: 30

Popular posts from this blog

Array in C Programming | C Programming

C program to Find Cartesian Product of Two Sets | C programming

What is System? | SAD