Loops-Python

Wed 12 November 2025
#  created : 20250111
#  https://www.scientecheasy.com/2022/10/loops-in-python.html/
count = 0
while count < 10:
    print('Hello world')
    count += 1
print('Loop finished')
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Loop finished
start, end = 10, 50
for …

Category: python-basics

Read More

Membership-Operator

Wed 12 November 2025
#  created : 20250113
#  https://www.scientecheasy.com/2022/10/membership-operators-in-python.html/
#  Membership In operator
# in 
# not in
my_string = 'Every person loves his country in the world.'
print('E' in my_string)
print('country' in my_string)
print('like' in my_string)
print('lo' in my_string)
True
True
False
True
my_list = [2, 4, 6, 8 …

Category: python-basics

Read More

Move-Zero

Wed 12 November 2025

def move_zeroes(lst):
    non_zero = [x for x in lst if x != 0]
    zeroes = [0] * lst.count(0)
    result = non_zero + zeroes
    print("List after moving zeroes:", result)

# Example usage
move_zeroes([0, 1, 0, 3, 12])
move_zeroes([0, 0, 0])
List after moving zeroes: [1, 3, 12, 0, 0]
List after moving …

Category: python-basics

Read More

Multible-Inheritance

Wed 12 November 2025
class Father:
    def skill(self):
        print("Driving")

class Mother:
    def skill(self):
        print("Cooking")

class Child(Father, Mother):
    pass

child = Child()
child.skill()
Driving
class GrandParent:
    def display(self):
        print("GrandParent Display")

class Parent(GrandParent):
    pass

class Child(Parent):
    pass

child = Child()
child.display()
GrandParent Display


Score: 0

Category: python-basics

Read More

Nested-If

Wed 12 November 2025
#  created : 20250125
#  https://www.scientecheasy.com/2022/10/python-nested-if.html/

x = 20
y = 10
z = 5
# Outer if statement.
if x > y:
    if y > z: # Nested inner if statement.
        print('Hello')
Hello
x = 20
y = 10
z = 5
# Outer if statement.
if x > y:
    if y < z: # Nested inner if …

Category: python-basics

Read More

Nested-Loop

Wed 12 November 2025
#  created : 20250125
#  https://www.scientecheasy.com/2022/11/nested-loops-in-python.html/

# Outer for loop.
for x in 1, 2:
    print('Value of x = ',x) # It will execute two times.
  # Inner for loop.
    for y in 1, 2:
        print('Value of y = ',y) # It will execute four times.
print('Nested loops ends …

Category: python-basics

Read More

Numpy-Pandas

Wed 12 November 2025
import pyutil as pyu
pyu.get_local_pyinfo()
'conda env: py311; pyv: 3.11.9 (main, Apr 19 2024, 16:48:06) [GCC 11.2.0]'
print(pyu.ps2("pandas"))
pandas==2.2.3
import pandas as pd;
import numpy as np;
sizes = np.full((10), 8, dtype=int);    
print(sizes);
[8 …

Category: pandas-work

Read More

Operator-Precedence

Wed 12 November 2025
#  created : 20250125
#  https://www.scientecheasy.com/2022/10/operator-precedence-in-python.html/
# Python Precedence Operator
# #  meaning of precedence operator:
# ------------------------------------
# Operator precedence in Python means the order in which the Python interpreter executes operators. 
# It tells the Python interpreter which operator should be evaluated first if a single statement contains more than one …

Category: python-basics

Read More

Overlaoding

Wed 12 November 2025
class Box:
    def __init__(self, length):
        self.length = length

    def __add__(self, other):
        return self.length + other.length

box1 = Box(10)
box2 = Box(20)
print("Total Length:", box1 + box2)
Total Length: 30


Score: 0

Category: python-basics

Read More

Palindrome

Wed 12 November 2025
def check_palindrome(input_string):
    # Check if the string is a palindrome (ignoring case)
    is_palindrome = input_string.lower() == input_string[::-1].lower()

    if is_palindrome:
        return f"{input_string} is a palindrome"
    else:
        return f"{input_string} is not a palindrome"

# Test the function
input_string = "Able was I ere I saw Elba"
print(check_palindrome(input_string))
Able was …

Category: python-basics

Read More
Page 7 of 10

« Prev Next »