By admin , 6 March, 2022

An algorithm is a collection of Sequence of steps to solve a particular problem.

 

By admin , 6 March, 2022

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

In Python, variables are used to store data values. Unlike some other programming languages, Python does not require explicit declaration of variables or their data types. Instead, variables are created when you assign a value to them.


Key Concepts of Variables in Python

  1. Variable Assignment
    • Use the = operator to assign a value to a variable.
    • Example:

      x = 10
      name = "Alice"

  2. Variable Naming Rules

    • Variable names must start with a letter (a-z, A-Z) or an underscore (_).
    • The rest of the name can contain letters, numbers, or underscores.
    • Variable names are case-sensitive (myVar and myvar are different).
    • Avoid using Python keywords (e.g., if, else, for, while, etc.) as variable names.
    • Use descriptive names for clarity (e.g., user_age instead of ua).

    Examples of valid variable names:

    age = 25
    _count = 10
    user_name = "Bob"
    total_amount = 100.50

    Examples of invalid variable names:

    2nd_place = "John"  # Cannot start with a number
    my-var = 10         # Hyphens are not allowed
    if = 5              # 'if' is a keyword

  3. Dynamic Typing
    • Python is dynamically typed, meaning you don't need to declare the type of a variable. The type is inferred from the value assigned.
    • Example:

      x = 10        # x is an integer
      x = "Hello"   # x is now a string

  4. Multiple Assignments
    • You can assign multiple variables in a single line.
    • Example:

      a, b, c = 1, 2, 3
      print(a, b, c)  # Output: 1 2 3

  5. Constants
    • Python does not have built-in support for constants, but by convention, constants are written in uppercase.
    • Example:

      PI = 3.14159


Example Code

# Variable assignment
name = "Alice"
age = 30
height = 5.5
# Printing variables
print("Name:", name)
print("Age:", age)
print("Height:", height)
# Reassigning a variable
age = 31
print("Updated Age:", age)
# Multiple assignments
x, y, z = 10, 20, 30
print("x:", x, "y:", y, "z:", z)
# Swapping variables
x, y = y, x
print("After swapping - x:", x, "y:", y)


Output

Name: Alice
Age: 30
Height: 5.5
Updated Age: 31
x: 10 y: 20 z: 30
After swapping - x: 20 y: 10


Key Points to Remember

  • Variables are created when you assign a value to them.
  • Python is dynamically typed, so variables can hold values of any type.
  • Use meaningful variable names to make your code more readable.

Let me know if you need further clarification or examples!

By admin , 2 March, 2022

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Step 1: Download the latest version to Install from official website https://visualstudio.microsoft.com/downloads/.

Step 2: Go to extension icon and search Python and enabled the extension.

extension

Step 3: Verify and select correct Python version in VS.

 open your .py file and see below in status bar

path

Step 4: Set file Execution In current File Dir.

Go to File->Preferences->settings and search "Execute In File Dir" make sure you have checked box .

Step 5: Set Customize Run and Debug for current working directory.

click on create a launch.json file and choose "Python File"  and add  lines at bottom 

 "cwd": "${fileDirname}",

cwd

By admin , 2 March, 2022

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Step 1: Download the latest version to Install from official website https://www.python.org/downloads/

Step 2: Run Executable Installer and make sure you select the Install launcher for all users and Add Python 3.7 to PATH checkboxes. and Select Install Now

python-setup

Step 3: The next dialog will prompt and select Disable path length limit

python-setup-completed

Step 4: Verify Python Was Installed On Windows using CMD python --version

CMD

Step 5: Congratulations!

... Comming Soon...
... Comming Soon...
By admin , 15 February, 2022

Programming

The process of creating a set of instructions that tell a computer how to perform a task. Programming can be done using a variety of computer programming languages, such as PHP, JAVA, JavaScript, Python, C and C++.

Coding :

implementation of algorithms in a target programming language.

String literal

pair of quotes 

Example  "         " or         '        '