Py20

Fri 17 April 2026
# Program 54: Copy File
def main():
    f1 = open("test.txt", "r")
    f2 = open("copy.txt", "w")

    data = f1.read()

    f2.write(data)

    f1.close()
    f2.close()

main()
---------------------------------------------------------------------------

FileNotFoundError                         Traceback (most recent call last)

Cell In[6], line 13
      9 
     10     f1.close()
     11     f2.close()
     12 
---> 13 main()


Cell In …

Category: misc

Read More

Py21

Fri 17 April 2026
# Program 57: Class
class Person:
    def show(self):
        print("Hello")

def main():
    p = Person()
    p.show()

main()
Hello
# Program 58: Constructor
class Person:
    def __init__(self, name):
        self.name = name

    def show(self):
        print("Name:", self.name)

def main():
    p = Person("Ram")
    p.show()

main()
Name: Ram
# Program 59: Inheritance …

Category: misc

Read More

Py22

Fri 17 April 2026
# Program 60: Override
class A:
    def show(self):
        print("A")

class B(A):
    def show(self):
        print("B")

def main():
    obj = B()
    obj.show()

main()
# Program 61: Calculator
def main():
    a = int(input("Enter first number: "))
    b = int(input("Enter second number: "))
    op = input("Enter operator (+,-,*,/): ")

    if op == '+':
        print("Result …

Category: misc

Read More

Py23

Fri 17 April 2026
# Program 63: Password Check
def main():
    password = "admin123"

    user = input("Enter password: ")

    if user == password:
        print("Access granted")
    else:
        print("Access denied")

main()
Enter password:  admin123


Access granted
# Program 64: Count Characters
def main():
    text = input("Enter text: ")

    count = {}

    for ch in text:
        count[ch] = count.get(ch, 0) + 1 …

Category: misc

Read More

Py24

Fri 17 April 2026
# Program 66: Tables 1–10
def main():
    for i in range(1, 11):
        print("Table of", i)

        for j in range(1, 6):
            print(i, "x", j, "=", i*j)

main()
Table of 1
1 x 1 = 1
1 x 2 = 2
1 x 3 = 3
1 x 4 = 4
1 …

Category: misc

Read More

Py25

Fri 17 April 2026
# Program 69: Sum Odd
def main():
    n = int(input("Enter limit: "))

    total = 0

    for i in range(1, n+1):
        if i % 2 != 0:
            total += i

    print("Sum of odd:", total)

main()
Enter limit:  7


Sum of odd: 16
# Program 70: Max Digit
def main():
    num = int(input("Enter number …

Category: misc

Read More

Py26

Fri 17 April 2026
# Program 72: Remove Spaces
def main():
    text = input("Enter text: ")

    result = ""

    for ch in text:
        if ch != " ":
            result += ch

    print("Without spaces:", result)

main()
Enter text:  thangappa thakkam


Without spaces: thangappathakkam
# Program 73: Uppercase Count
def main():
    text = input("Enter text: ")

    count = 0

    for ch in text:
        if ch.isupper …

Category: misc

Read More

Py27

Fri 17 April 2026
# Program 75: Find Index
def main():
    nums = list(map(int, input("Enter numbers: ").split()))
    target = int(input("Enter element: "))

    for i in range(len(nums)):
        if nums[i] == target:
            print("Index:", i)
            break

main()
Enter numbers:  1 2 3
Enter element:  123
# Program 76: Count Occurrence
def main():
    nums = list …

Category: misc

Read More

Py28

Fri 17 April 2026
# Program 78: Check Sorted
def main():
    nums = list(map(int, input("Enter numbers: ").split()))

    if nums == sorted(nums):
        print("Sorted")
    else:
        print("Not sorted")

main()
Enter numbers:  1 2 3 4 5


Sorted
# Program 79: Matrix Sum
def main():
    m = [[1,2],[3,4]]

    total = 0

    for row in m …

Category: misc

Read More

Py29

Fri 17 April 2026
# Program 81: Count Positive
def main():
    nums = list(map(int, input("Enter numbers: ").split()))

    count = 0

    for n in nums:
        if n > 0:
            count += 1

    print("Positive count:", count)

main()
Enter numbers:  12 34 56 7


Positive count: 4
# Program 82: Count Negative
def main():
    nums = list(map(int, input …

Category: misc

Read More
Page 2 of 4

« Prev Next »