0% found this document useful (0 votes)
5 views2 pages

AMLW Assignment 1

Uploaded by

nisambhai92
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)
5 views2 pages

AMLW Assignment 1

Uploaded by

nisambhai92
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
You are on page 1/ 2

Centre for Artificial Intelligence Machine Learning

Institute of Technical Education & Research, SOA, Deemed to be University

Applied Machine Learning Workshop (CSE 3193)


A SSIGNMENT-1: BASIC OF P YTHON P ROGRAMMING

1. Evaluate the following expressions involving arithmetic, relational and logical operators:
a. 5 % 10 + 10 < 50 and 29 >= 29
b. 7 ** 2 <= 5 // 9 % 3 or ’bye’ < ’Bye’
c. 5 % 10 < 8 and -25 > 1 * 8 // 5
d. 7 ∗∗ 2 // 4 + 5 > 8 or 5 != 6
e. 7/4 < 6 and ’I am fine > ’I am not fine’
f. 10 + 6 * 2 ** 2 != 9//4-3 and 29 >= 29/9
g. ’hello’ * 5 > ’hello’ or ’bye’ < ’Bye’

2. Write a python function to input the height of three friends Rahul, Raj and Ramesh and find the friend
with smallest height using conditional statement.

3. Write a python function to check a year inputted by the user is a leap year or not.

4. Write a program that reads three integers from the user and displays them in sorted order (from
smallest to largest). Use the min and max functions to find the smallest and largest values. The middle
value can be found by computing the sum of all three values, and then subtracting the minimum value
and the maximum value.

5. Write a function areaTriangle that takes the lengths of three sides: side1, side2, and side3 of the
triangle as the input parameters and returns the area of the triangle as the output. Also, assert that sum
of the length of any two sides is greater than the third side. Write a function main that accepts inputs
from the user interactively and computes the area of the triangle using the function areaTriangle.

6. Observe carefully the below function


def fun(a=0, b=1):
return (a**2 + b**2)
What will be the output for each call made below?
a. fun(2,a=3)
b. fun(b=3,2)
c. fun(3,b=2)
d. fun(a=4,5)

7. Write a program that takes two numbers as input and check whether they are co-primes.
[Hint :Two numbers are said to be co-prime if they do not have any common divisor other than one.]

8. Study the program segments given below. In each case, give the output produced, if any.
a. total = 0
count = 20
while count > 5:
total + =count
count − =1
print(total)
b. total = 0
N =5
for i in range (1,N+1):
for j in range (1,i+1):
1
Centre for Artificial Intelligence Machine Learning
Institute of Technical Education & Research, SOA, Deemed to be University

total + =1
print(total)

9. Write a python program to find the sum of the digits of a number. If a number is 314 then sum of the
digits are 10.

10. What will be the output on executing each of the following assignment statements:
address =’B-6, Lodhi road, Delhi’
a. len(address)
b. address[17:-1]
c. address[-len(address): len(address)]
d. address[:-12] + address[-12:]
e. address.find(’delhi’)
f. address.swapcase()
g. address.split(’,’)
h. address.isalpha()

11. Write a python program to input a list of n elements and return a list having no duplicate elements
without using any built-in function.

12. Write a python program to generate a list which contains the cubes of first 10 natural number using
list comprehension.

13. Write a python program to find the occurrence of each character present in a string use the oncept of
python dictionary.

14. Write a python function that takes a number as an input parameter and returns the correspond text in
words. Use a dictionary for mapping digits to their string representation.
[Example : On input 452, the function should return ’Four Five Two’. ]

You might also like