Getting started with Python🐍

🐍👋Welcome to the Python world!

Python is a strong and widely used programming language that has various applications, ranging from web development to scientific computing.

In this blog, we'll go through the fundamentals of Python and would see some fun and helpful examples to get you started.

👨‍💻 Let's go!

Before jumping directly into it, let's make sure you have everything you need to get started with Python.

To begin,

  1. Download and install Python from the official website.

  2. Once Python is installed, open a command prompt or terminal window and type python to launch the interactive Python shell.

🤖 Example 1: Hello World!

The standard "Hello World" program is an excellent introduction to any programming language.

Just enter the following code into your Python shell to print the phrase "Hello World"

print("Hello World!")

🧮 Example 2: Simple Math

Python may also be used for basic math tasks. To add two integers together, for example, use the following code:

x = 3 
y = 5 
z = x + y 
print(z)

In this example, we define two variables, x and y and give them the values 3 and 5, respectively. We next establish a third variable, z and assign the sum of x and yto it.

Lastly, we use the print method to print z to the console.

🔢 Example 3: FizzBuzz

FizzBuzz is a famous programming challenge in which you print out integers from 1 to 100, but replace multiples of 3 with Fizz, multiples of 5 with Buzz, and multiples of both 3 and 5 with FizzBuzz.

In Python, here's how to solve the FizzBuzz problem:

for i in range(1, 101):
    if i % 3 == 0 and i % 5 == 0:
        print("FizzBuzz")
    elif i % 3 == 0:
        print("Fizz")
    elif i % 5 == 0:
        print("Buzz")
    else:
        print(i)

In this example, we cycle through the numbers 1 to 100 using a for loop. Next, using a sequence of if statements, we assess if the current number is a multiple of 3, 5, or both. We print FizzBuzz if it is a multiple of both. We print Fizz if the number is just a multiple of 3. We print Buzz if the number is just a multiple of 5.

In the absence of such, we just publish the current number.

Thanks for reading so far!

This is just a short introduction... But surely will deep dive into topics in detail in my upcoming blogs.

So today's conclusion,

Python is a flexible and strong programming language that is suitable for both inexperienced and experienced developers as it has a wide range of applications.

So go ahead and start exploring the Python universe now!

Thank you for reading so far!

If you find this information helpful then do like, share, and subscribe to my newsletter to get updated whenever I post a new blog.

Read my other blogs:

Did you find this article valuable?

Support Preksha Thakkar by becoming a sponsor. Any amount is appreciated!