Learning some basics of python

🚀 Basics of Python – A Beginner's Guide

Welcome to the beginner's corner of Python programming! In our previous blog, we covered some of the fundamentals. Now, let’s dive into the core basics to build a strong foundation. Whether you’re learning for the first time or revising, this guide is here to help you step by step. 🐍



What is Python?

Python is a high-level, interpreted programming language known for its easy and readable syntax. It’s widely used in fields like:

  • Web development

  • Data science

  • Machine learning

  • Automation

  • Scripting

Its simplicity makes it an ideal choice for beginners.

Installing Python

  1. Download Python from https://www.python.org
  2. Install it, and during installation, check the box "Add to PATH"
  3. Verify installation using:

Here we are going to use the interpreter for python that is pycharm.

✅ Writing Your First Python Program:

Create a file named hello.py and write:

Going to write our first Program to print any text or any statement in python.

For that purpose we uses the function called "print()".

Syntax to use print() is as follow:

print("Type the statement here that you want to print")

Example: Print("Hello Python")

Output: Hello Python

Python Syntax and Data Types

➡️ Variables

A variable is used to store data. Python is dynamically typed, so you don’t need to declare the type explicitly:

name = "Raghav"  # String

age = 25         # Integer

height = 5.9     # Float

is_coder = True  # Boolean

➡️ Data Types:

Data     TypeExample      Description
int      10, -5, 0              Whole numbers
float    3.14, -2.5            Decimal numbers
str       "Hello"               Text values
bool     True,False           Boolean values
list     [1, 2, 3]            Ordered, mutable collection


Lets talk about some more built in functions of python:

1. input():

The input() function allows user input from the keyboard.

Syntax:

input(prompt)

promptA string displayed to the user before taking input

Example:

                                     name = input("Enter your name: ")
                                     print("Hello, " + name)           Output: Helloname

2. int(), float(), str()

These are type conversion functions:

  • int() Converts to integer

  • float()Converts to float

  • str() Converts to string

Example:

                                  num = int(input("Enter a number: ")) #let the number be 10

                                       print(num * 2)          Output: 10*2=20


Conditional Statements

Conditional statements allow decision-making in Python.

3. if, elif, else:

Syntax:
               


Example:
                                                    age = 20
                                                    if age >= 18:
                                                         print("Adult")
                                                    elif age < 18 and age > 12:
                                                         print("Teenager")
                                                    else:
                                                         print("Child")

Now let us take one more question as an example of if ,elif and else conditions programme: 

Question: Suppose you are Samar pratabh singh. His teacher asked him to make a programme in which user enters the age of the person as the input then the programme as +ve wheather the entered value is +ve or -vely entered.

programme: 
age= int(input("enter the age"))
if age<0:
print(-1*(age))
else:
print(age)
Now Let me give you one-two question which you will try at your home and I will give the soln in next Blog:

Question: Suppose Mohan's Mother is working in a factory and she got the task from her boss to sort the list of the members Started with M and N. Write the programme which print\show "inserted in list1" when name starts with M and show "inserted in list 2" when name started with N. 
Question: Suppose your father is the head of the labour factory and He wants to sort the name of the labour on the basis of their wadges. Wether they are rich or poor. So, write the programme to help him. 
Question: Suppose you are Reema head Girl of the class and your class teacher asked you to sort the student in the category of height as shortest , short , tall and tallest. So, create a programme for helping your teacher to short the students.

✅ Conclusion

That's all for today’s basic introduction to Python! 🚀
I hope you understood how easy and fun Python can be if you just follow step-by-step. Now, it's your turn to practice the questions I gave at the end — don’t worry, I’ll share the solutions in my next blog. 

👉 In the next part, we will dive deeper into loops in Python where you’ll learn how to run your code multiple times without repeating yourself. You can check it out here: Loops in Python – While & For Loops Explained🔄

Keep learning, keep practicing, and coding will become your best friend. See you in the next blog! ✨

Post a Comment

2 Comments