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

Week-5 Lab

pyhton

Uploaded by

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

Week-5 Lab

pyhton

Uploaded by

nikhilverma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

---------------------------------------------

Week-5 Practice problems on Functions:


---------------------------------------------

1. Write a Python function to calculate the factorial of a number (a non-negative


integer).

2. Write a Python function to return the Max, Min of a given list of items

3. Write a Python function to sum all the numbers in a list.

4. Write a Python function that accepts a string and calculate the number of upper
case letters and lower case letters

5. Write a function that returns N random numbers in the range [P,Q], with the
following constraints:
i) N <= Q-P+1
ii) No duplicates in the result

Part B:

write a function to rearrange the elements in a list (Use the above function)

6. Write a Python function that takes a list and returns a new list with unique
elements of the first list.

7. Generate 100 random integers in the range [1,6]. Count how many '1's, '2's, ...,
'6's. Can it be used as a fair die.

8. Write a Python function to check whether a number is perfect or not. (A perfect


number is a positive integer that is equal to the sum of its proper positive
divisors,
Example : 6 is a first perfect number, 1, 2, and 3 are its proper positive
divisors, and 1 + 2 + 3 = 6.

9. Write a Python function to check whether a string contains every letter of the
alphabet at least once.

10. Write a Python program that accepts a comma-separated sequence of words as


input and
prints the words in a hyphen-separated sequence after sorting them alphabetically.

11. Write a Python program to execute a string containing Python code.

12. Write a Python program that prints 1 .. 10, After printing a number, it wait
for 1 sec.

13. Randomly change element positions of a given list.

14. Copy elements from one list to the other list. Using list comprehension and
without list comprehension
15. Implement K-Means algorithm (Explain the logic, with example by instructor.
Implementation by students)
16. Curse of dimentionality:
a) Genate 10 points randomly in the range [0,1]. Find the average distance
between any two points.
b) repeat the same problem for dimensions 1, 3, 10, 100
c) plot a graph between dimensions and the avergage distance.
17. Implement K-NN algorithm

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy