ntroduction to Python (Basics)


Python is a popular, high-level programming language created by Guido van Rossum and first released in 1991. It is used in web development, software development, data science, artificial intelligence, automation, and more. Python's simple and readable syntax makes it one of the best languages for beginners.


**Why use Python?**

- Easy to learn with syntax close to English.

- Versatile and supports procedural, object-oriented, and functional programming.

- Works on multiple platforms (Windows, Mac, Linux).

- Large ecosystem of libraries and frameworks.

- Interpreter-based for quick testing and prototyping.


***


## Python Basics Concepts


### 1. Output

You can display output with the `print()` function.


Example:

```python

print("Hello, World!")

```


### 2. Variables and Data Types

Variables store information. Common types:

- Integers (`int`): whole numbers (e.g., 3, 100)

- Floats (`float`): decimal numbers (e.g., 3.14)

- Strings (`str`): text enclosed in quotes (e.g., "Python")

- Booleans (`bool`): True or False


Example:

```python

name = "Alice"

age = 25

is_student = True

print(name, age, is_student)

```


### 3. Input

Use `input()` to get user input (always returns a string).


Example:

```python

age = input("Enter your age: ")

print("You entered:", age)

```


For numeric input, convert using `int()` or `float()`.


### 4. Conditional Statements

Run code based on conditions using `if`, `elif`, and `else`.


Example:

```python

if age >= 18:

    print("You are an adult.")

else:

    print("You are a minor.")

```


### 5. Loops

Repeat code multiple times.


- `for` loop: iterate over a sequence

- `while` loop: repeat while a condition is true


Example:

```python

for i in range(5):

    print(i)

```


***


## Practice Problems and Examples


### Problem 1: Print your name

Write a program that prints your name.


```python

print("Your Name")

```


***


### Problem 2: Add two numbers

Read two numbers from the user and print their sum.


```python

num1 = int(input("Enter first number: "))

num2 = int(input("Enter second number: "))

print("Sum:", num1 + num2)

```


***


### Problem 3: Check even or odd

Write a program that decides if a number is even or odd.


```python

num = int(input("Enter a number: "))

if num % 2 == 0:

    print("Even")

else:

    print("Odd")

```


***


### Problem 4: Print numbers divisible by 5 from a list


```python

num_list = [10, 20, 33, 46, 55]

print("Divisible by 5:")

for num in num_list:

    if num % 5 == 0:

        print(num)

```


***


### Problem 5: Count vowels in a string

Write a function to count vowels in a given string.


```python

def count_vowels(s):

    vowels = "aeiouAEIOU"

    count = 0

    for char in s:

        if char in vowels:

            count += 1

    return count


print(count_vowels("Hello World"))

```


***


### Problem 6: Find factorial of a number using loop


```python

num = int(input("Enter a number: "))

factorial = 1

for i in range(1, num+1):

    factorial *= i

print("Factorial:", factorial)

```


***


### Problem 7: Reverse a string


```python

s = input("Enter a string: ")

print("Reversed string:", s[::-1])

```


***


### Problem 8: Simple calculator function


```python

def calculator(a, b, op):

    if op == '+':

        return a + b

    elif op == '-':

        return a - b

    elif op == '*':

        return a * b

    elif op == '/':

        return a / b

    else:

        return "Invalid operator"


print(calculator(6, 3, '*'))

```


***


### Problem 9: Check if a string is a palindrome


```python

def is_palindrome(s):

    return s == s[::-1]


print(is_palindrome("radar")) # True

print(is_palindrome("hello")) # False

```


***


## Summary

Python is an accessible language that beginners can quickly start coding in. These basics and practice problems form a strong foundation for further learning and application in projects.


***


This explanation and examples can be directly posted on a Blogger page to help students learn Python programming step-by-step with hands-on problems for practice.


If needed, further detailed tutorials or problem sets can be created as well.


[1](https://www.w3schools.com/python/python_intro.asp)

[2](https://www.geeksforgeeks.org/python/python-basics/)

[3](https://www.python.org/about/gettingstarted/)

[4](https://developers.google.com/edu/python/introduction)

[5](https://en.wikipedia.org/wiki/Python_(programming_language))

[6](https://www.codecademy.com/resources/blog/python-code-challenges-for-beginners/)

[7](https://www.geeksforgeeks.org/python/python-programming-language-tutorial/)

[8](https://docs.python.org/3/tutorial/index.html)

[9](https://pynative.com/python-basic-exercise-for-beginners/)

[10](https://www.pythontutorial.net)

[11](https://www.youtube.com/watch?v=fLAfa-BQtOQ)

[12](https://www.geeksforgeeks.org/python/python-exercises-practice-questions-and-solutions/)

[13](https://www.youtube.com/watch?v=K5KVEU3aaeQ)

[14](https://aws.amazon.com/what-is/python/)

[15](https://www.codechef.com/practice/python)

[16](https://www.tutorialspoint.com/python/index.htm)

[17](https://www.coursera.org/in/articles/what-is-python-used-for-a-beginners-guide-to-using-python)

[18](https://www.hackerrank.com/domains/python)

[19](https://www.youtube.com/playlist?list=PLu0W_9lII9agwh1XjRt242xIpHhPT2llg)

[20](https://www.w3schools.com/python/)