425 Assignment
425 Assignment
Assignment-2
CSE425.9
Submitted by
Faizur Rahim Raheeb 2031043042
Submitted on
23th May 2024
1. Write a Program to Find the Length of the String Without using
strlen() Function.
Code:
length = 0
length += 1
Code:
def is_palindrome(s):
return s == s[::-1]
class Point:
self.x = x
self.y = y
def __str__(self):
p1 = Point(1, 2)
p2 = Point(3, 4)
p3 = p1 + p2
class Math:
return a + b + c
math_obj = Math()
4. Write a Program for the Implementation of Stacks Using an Array using object
oriented modeling.
Code:
class Stack:
def __init__(self):
self.stack = []
self.stack.append(item)
def pop(self):
if not self.is_empty():
return self.stack.pop()
else:
def peek(self):
if not self.is_empty():
return self.stack[-1]
else:
def is_empty(self):
return len(self.stack) == 0
def size(self):
return len(self.stack)
my_stack = Stack()
my_stack.push(1)
my_stack.push(2)
my_stack.push(3)
Code:
#include <iostream>
if (index < 0) {
return;
int main() {
string test_string;
getline(cin, test_string);
printReverse(test_string, test_string.length() - 1);
return 0;