Posts

Showing posts with the label Python Theory

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

Function In Python Programming | Python Programming

What is a function in Python? In Python, a function is a group of related statements that perform a specific task. Functions help break our program into smaller and modular chunks. As our program grows larger and larger, functions make it more organized and manageable. Furthermore, it avoids repetition and makes code reusable. You can define functions to provide the required functionality. Here are simple rules to define a function in Python. Function blocks begin with the keyword  def  followed by the function name and parentheses ( ( ) ). Any input parameters or arguments should be placed within these parentheses. You can also define parameters inside these parentheses. The first statement of a function can be an optional statement – the documentation string of the function or  docstring . The code block within every function starts with a colon (:) and is indented. The statement return [expression] exits a function, optionally passing back an expression to the ca

Python Programming Looping Techniques, For Loop in Python Programming and While Loop in Python Programming | Python Programming

Image
Python Programming Looping Techniques, For Loop in Python Programming and While Loop in Python Programming For loop in Python Programming What is for loop in Python Programming? The for loop in Python Programming is used to iterate over a sequence (list, tuple, string) or other iterable objects. Iterating over a sequence is called traversal. Syntax of for Loop for val in sequence:     Body of for Here, val is the variable that takes the value of the item inside the sequence on each iteration. Loop continues until we reach the last item in the sequence. The body of for loop is separated from the rest of the code using indentation. Flowchart of for Loop Example: Python for Loop # Program to find the sum of all numbers stored in a list # List of numbers numbers = [ 6 , 5 , 3 , 8 , 4 , 2 , 5 , 4 , 11 ] # variable to store the sum sum = 0 # iterate over the list for val in numbers:     sum = sum +val # Output: The sum is 48 print ( "The sum is" , sum ) when you run th

Python Programming Namespace | Python Programming

Image
What is Name in Python Programming? A namespace is a system to have a unique name for each and every object in Python. An object might be a variable or a method. Python itself maintains a namespace in the form of a Python dictionary.  Namespaces are one honking great idea -- let's do more of those!  

Python Programming Type Casting/Conversion, Frozen Set | Python Programming

Python Programming Type Casting/Conversion: The process of converting the value of one data type such as integer, string, float, etc. to another data type is called type conversion/ typecasting. Python has two types of type conversion/typecasting. Implicit Type Conversion Explicit Type Casting

Popular posts from this blog

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

Array in C Programming | C Programming

What is System? | SAD