Inheritance

Wed 12 November 2025
class Animal:
    def speak(self):
        print("Animal speaks")

class Dog(Animal):
    def speak(self):
        print("Dog barks")


dog_barks = Dog()
dog_barks.speak()
Dog barks


Score: 0

Category: python-basics

Read More

Iteration-Keyword

Wed 12 November 2025
#  created : 20250111
#  https://www.scientecheasy.com/2022/09/reserved-keywords-in-python.html/
#  python iteration keyword
for count in range(1, 4):
  print("Scientech Easy, Dhanbad")
Scientech Easy, Dhanbad
Scientech Easy, Dhanbad
Scientech Easy, Dhanbad
count = 0
while(count < 3):
    print("The current count is: ", count)
    count = count + 1
print("While loop ended …

Category: python-basics

Read More

Largest-Number

Wed 12 November 2025
def second_largest(nums):
    nums.remove(max(nums))
    return max(nums)

# Test the function
nums = [10, 20, 30, 40, 50]
print("Second largest number:", second_largest(nums))
Second largest number: 40


Score: 0

Category: python-basics

Read More

List-Exists

Wed 12 November 2025
def separate_even_odd(lst):
    even = []
    odd = []
    for num in lst:
        if num % 2 == 0:
            even.append(num)
        else:
            odd.append(num)
    print("Even Numbers:", even)
    print("Odd Numbers:", odd)

# Example usage
separate_even_odd([1, 2, 3, 4, 5, 6])
Even Numbers: [2, 4, 6]
Odd Numbers: [1, 3, 5]


Score: 0

Category: python-basics

Read More

List-Frequence

Wed 12 November 2025
from collections import Counter
def frequency():
    nums = list(map(int, input("Enter the numbers (separated by spaces): ").split(',')))
    frequency = Counter(nums)
    print("Element frequencies:", frequency)
frequency()
Enter the numbers (separated by spaces):  1,23,4,5,64,4,3,2


Element frequencies: Counter({4: 2, 1: 1, 23: 1, 5 …

Category: python-basics

Read More

List-Palindromnic

Wed 12 November 2025

def is_list_palindrome(lst):
    start = 0
    end = len(lst) - 1
    while start < end:
        if lst[start] != lst[end]:
            print("The list is not a palindrome.")
            return
        start += 1
        end -= 1
    print("The list is a palindrome.")

# Example usage
is_list_palindrome([1, 2, 3, 2, 1])
is_list_palindrome([1, 2, 3])
The list is …

Category: python-basics

Read More

Logical-Operators

Wed 12 November 2025
#  created : 20250113
#  https://www.scientecheasy.com/2022/10/logical-operators-in-python.html/
#  x > y and y > z # Two relational expressions combined by a logical and operator.
#  Types of Logical or Boolean Operators in Python
# and
#  or 
#  not
# Logical AND Operator
x, y = 10, 5
result = (x == 10 and y == 5) 
print(result …

Category: python-basics

Read More

Logical-Operators-In-If-Statements

Wed 12 November 2025
#  created : 20250125
#  https://www.scientecheasy.com/2022/10/if-statement-in-python.html/
def logical():
    x, y, z = 20, 40, 50
    if((y > x) and (y < z)): # True 
         print("y is greater than x but smaller than z") 
    if((x > y) and (y < z)): # False
         print("z is greater than x, y")
    if …

Category: python-basics

Read More

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
Page 5 of 8

« Prev Next »