0% found this document useful (0 votes)
9 views4 pages

Python Programming Assignment Guide

This document outlines an assignment for a Python programming course at Maharaja Agrasen Institute of Technology, focusing on various programming tasks. It includes building a temperature converter, analyzing outputs of given code snippets, creating a text analysis tool, and identifying syntax errors in function definitions. The assignment is structured into five questions with specified marks for each.

Uploaded by

NAMAN MANGLA
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Python Programming Assignment Guide

This document outlines an assignment for a Python programming course at Maharaja Agrasen Institute of Technology, focusing on various programming tasks. It includes building a temperature converter, analyzing outputs of given code snippets, creating a text analysis tool, and identifying syntax errors in function definitions. The assignment is structured into five questions with specified marks for each.

Uploaded by

NAMAN MANGLA
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MAHARAJA AGRASEN INSTITUTE OF TECHNOLOGY

Subject Name-Programming in Python ​ ​ ​ Subject Code- CIE-332T

Assignment 1

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ Marks : 30

Q.1 Build a temperature converter program that converts temperatures between Celsius and
Fahrenheit. Also show how you would use control structures to prompt the user for input,
perform the conversion, and display the result. ​ ​ ​ ​ ​ (5) (CO1)

Q.2 What will be output of the program​ ​ ​ ​ ​ ​ (4)

(a) ​ numbers = [1, 2, 3]​ ​ ​ ​ ​ ​ ​ ​ (CO1)​

for i in range(len(numbers)):

​ ​ [Link](numbers[i])

print(numbers)

(b) ​ numbers = [1, 2, 3, 4, 5]​ ​ ​ ​ ​ ​ (CO1)​

for i in range(len(numbers)):

​ ​ if numbers[i] % 2 == 0:

​ ​ [Link](i+1, numbers[i] + 1)

print(numbers)

Q.3 Create a text analysis tool that analyzes a given text and provides various insights, such as
word count, character count, most frequent word, Word Frequency, Reverse Text, Palindrome,
Check Uppercase and Lowercase Conversion and Remove Punctuation.​ ​ ​ ​
​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ (5) (CO2)

Q.4 What will be output of the program​ ​ ​ ​ ​ ​ (6)

(a ) def main(a):​ ​ ​ ​ ​ ​ ​ ​ ​ (CO1)​

a = a + '2'

a=a*2

return a

main("byte")
(b) ​ def Withdef(HisNum = 30):​ ​ ​ ​ ​ ​ ​ ​ (CO1)

​ ​ for i in range(20,HisNum+1,5):

​ ​ ​ print(i, end=" ")

​ ​ print()

def Control(MyNum):

​ ​ MyNum = MyNum + 10

​ ​ Withdef(MyNum)

YourNum = 25;

Control(YourNum);

Withdef();

print("Number = " ,YourNum)

(c) ​ def Position(C1, C2, C3):​ ​ ​ ​ ​ ​ ​ ​ (CO1)

​ ​ C1[0] = C1[0] + 2

​ ​ C2 = C2 + 1

​ ​ C3 = "python"

​ ​ P1 = [20]

​ ​ P2 = 4

​ ​ P3 = "school"

​ ​ Position(P1, P2, P3);

​ ​ print(P1, ", ", P2, ", ", P3)

Q.5 Identify the syntax error in the following function definition:​ ​ ​ ​ (10)​

(a) ​ def greet(name)​ ​ ​ ​ ​ ​ ​ ​ ​ (CO1)

​ ​ print("Hello, " + name + "!")

(b) ​ def multiply(a, b):​ ​ ​ ​ ​ ​ ​ ​ ​ (CO1)

​ ​ return a * b
result = multiple(3, 5)

print(result)

(c) ​ def outer_function():​ ​ ​ ​ ​ ​ ​ ​ ​ (CO1)

​ ​ x = 10

​ ​ def inner_function():

​ ​ ​ return x * 2

​ ​ return inner_function()

result = outer_function()

print(result)

(d)​ Str1 = "EXAM2020"​​ ​ ​ ​ ​ ​ ​ ​ (CO2)

Str2 = ""

I=0

while I<len(Str1):

​ ​ if Str1[I]>="A" and Str1[I]<="M":

​ ​ ​ Str2=Str2+Str1[I+1]

​ ​ elif Str1[I]>="0" and Str1[I]<="9":

​ ​ ​ Str2=Str2+ (Str1[I-1])

​ ​ else:

​ ​ ​ Str2=Str2+"*"

​ ​ I=I+1

print(Str2)

(e) ​ Str1 = "EXAM2020"​ ​ ​ ​ ​ ​ ​ ​ ​ (CO2)

​ Str2 = ""

​ I=0

while I<len(Str1):
​ ​ if Str1[I]>="A" and Str1[I]<="M":

​ ​ ​ Str2=Str2+Str1[I+1]

​ ​ elif Str1[I]>="0" and Str1[I]<="9":

​ ​ ​ Str2=Str2+ (Str1[I-1])

​ ​ else:

​ ​ ​ Str2=Str2+"*"

​ ​ ​ I=I+1

print(Str2)

You might also like