0% found this document useful (0 votes)
235 views8 pages

Problem Solving and Python Programming Assignment - III

This document appears to be an assignment from the Department of Computer Science and Engineering at Rajalakshmi Engineering College in Chennai, India. The assignment covers topics related to problem solving and Python programming, including matching definitions, drawing stack diagrams, rewriting code, and searching built-in functions and string methods. It contains multiple sections for students to complete, focusing on Python concepts like functions, parameters, recursion, and strings.

Uploaded by

bhuvangates
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
235 views8 pages

Problem Solving and Python Programming Assignment - III

This document appears to be an assignment from the Department of Computer Science and Engineering at Rajalakshmi Engineering College in Chennai, India. The assignment covers topics related to problem solving and Python programming, including matching definitions, drawing stack diagrams, rewriting code, and searching built-in functions and string methods. It contains multiple sections for students to complete, focusing on Python concepts like functions, parameters, recursion, and strings.

Uploaded by

bhuvangates
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 8

RAJALAKSHMI ENGINEERING COLLEGE

Thandalam, Chennai 602 105

Department of Computer Science and Engineering

GE17151 PROBLEM SOLVING AND PYTHON PROGRAMMING

Unit - III - Assignment

Reg. No. : Name :

Year : Branch: Section:

I. Match me:

def area(width, height):


a = width * height
return a
w = float(input())
h = float(input())
r = area(w, h)

Column A Column B
def Function call
area Argument
width, height Function body
def area(width, height): Return expression
a Local variable
return a Function header
a = width * height
Parameters
return a
w,h Function name
area(w, h) Keyword
II. Complete me (Mark the Flow of Execution):

III. Draw me (Stack Diagram):

def repeat_times(string, times):


rep = string * times
print_twice(rep)
def print_twice(bruce):
print(bruce)
print(bruce)

s = 'REC'
t = 3
repeat_times(s, t)

2 B.BHUVANESWARAN | AP (SG) | CSE | Rajalakshmi Engineering College | Chennai


IV. Rewrite me properly:

Column A Column B
def area(radius):
a = math.pi * radius**2
return a
def absolute_value(x):
if x < 0:
return -x
else:
return x
def is_divisible(x, y):
if x % y == 0:
return True
else:
return False

V. Rewrite me properly (Recursive functions):

Column A Column B
def countdown(n):
if n <= 0:
print('Blastoff!')
else:
print(n)
countdown(n-1)
def print_n(s, n):
if n <= 0:
return
print(s)
print_n(s, n-1)
def factorial(n):
if n == 0:
return 1
else:
recurse = factorial(n-1)
result = n * recurse
return result
def fibonacci (n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return fibonacci(n-1)+ fibonacci(n-2)

B.BHUVANESWARAN | AP (SG) | CSE | Rajalakshmi Engineering College | Chennai 3


VI. Draw me (Stack Diagram):

def factorial(n):
if n == 0:
return 1
else:
recurse = factorial(n-1)
result = n * recurse
return result
f = factorial(3)

VII. Match me:

Column A Column B
def printme(str):
print(str) Variable-length arguments
printme("REC")
def printinfo(name, age):
print ("Name :", name)
Default arguments
print ("Age :", age)
printinfo(age = 19, name = "Arun")
def printinfo(name, age = 19):
print ("Name :", name)
print ("Age :", age) Keyword arguments
printinfo("Arun", 20)
printinfo("Babu")
def printargs(*vartuple):
print("Arguments are :")
for i in vartuple:
Required arguments
print(i)
printargs(10, 20)
printargs(10, 20, 30)

4 B.BHUVANESWARAN | AP (SG) | CSE | Rajalakshmi Engineering College | Chennai


VIII. Search at least 10 Pythons built-in functions:

Pythons Built-in Functions

B.BHUVANESWARAN | AP (SG) | CSE | Rajalakshmi Engineering College | Chennai 5


IX. Fill me:

>>> s = "Rajalakshmi engineering college"

Column A Column B
>>> s.capitalize()
>>> s.casefold()
>>> s.count("a")
>>> s.endswith("logy")
>>> s.endswith("lege")
>>> s.find("lakshmi")
>>> s.index("lakshmi")
>>> s.isalnum()
>>> s.isalpha()
>>> s.isdecimal()
>>> s.isdigit()
>>> s.islower()
>>> s.isnumeric()
>>> s.isspace()
>>> s.istitle()
>>> s.isupper()
>>> s.lower()
>>> s.replace("Raja", "Maha")
>>> s.split(" ")
>>> s.startswith("Raja")
>>> s.swapcase()
>>> s.title()
>>> s.upper()

6 B.BHUVANESWARAN | AP (SG) | CSE | Rajalakshmi Engineering College | Chennai


X. Search at least 10 Pythons string methods:

Pythons String Methods

B.BHUVANESWARAN | AP (SG) | CSE | Rajalakshmi Engineering College | Chennai 7


XI. Write me:

8 B.BHUVANESWARAN | AP (SG) | CSE | Rajalakshmi Engineering College | Chennai

You might also like