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

Lab Manual 6

1. The lab manual contains 8 tasks to be completed involving programming concepts like prime numbers, averages, lists, recursion, debugging, strings, and problem sets. 2. Task 5 involves using a debugging tool to determine the values of a variable at different points in a code sample. 3. Task 7 involves string and list methods like list(), split(), count(), index(), and join() to manipulate and analyze the string "i_love_python".

Uploaded by

Make it possible
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)
44 views2 pages

Lab Manual 6

1. The lab manual contains 8 tasks to be completed involving programming concepts like prime numbers, averages, lists, recursion, debugging, strings, and problem sets. 2. Task 5 involves using a debugging tool to determine the values of a variable at different points in a code sample. 3. Task 7 involves string and list methods like list(), split(), count(), index(), and join() to manipulate and analyze the string "i_love_python".

Uploaded by

Make it possible
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

Lab Manual 6

The following tasks are to be completed in the lab. Follow the think-code-test-debug procedure. Write the algorithm of
each task on a separate page.

1. Write a program to calculate and print all the prime numbers from 1 to 100. Use the function prime no which takes
no formal argument and nothing is returned back.
2. Write a program to calculate the average of all the numbers entered by the user. Keep taking input from the user until
the user enters -1.
3. Use list to print the following table.
a. Create two lists to store marks and grades. Use both the lists to print the following table.
b. Create two lists to store marks and grades. Store both the lists into another single list and then using this single
list to print the following table.

Marks Grade
Above 90 A+
80-90 A-
70-80 B+
60-70 B-
50-60 C+
Less than 50 F

4. Write a program which uses recursive function power(base, exponent) that when invoked returns

For example, power(3, 4) = 3 * 3 * 3 * 3. Assume that exponent is an integer greater than or equal to 1.
Hint: The recursion step would use the relationship

and the terminating condition occurs when exponent is equal to 1 because

5. For the following code, use the debugging mode of the SPYDER software to determine the following values.
a. The value of y just before the 2nd for loop starts.
b. The value of y just before the 3rd for loop starts.
c. The value of y just before the 4th for loop starts.
6. Write the following code and determine its output.
a. What is the output?
b. Will lists L1 and L change while the for loop is being executed? Use debugging mode to answer. L1 is called an
_______ of L.
c. Use cloning to print all the values from 1 to 5.
d. Modify the code so that L is a tuple and the output displays all integers from 1 to 5.

7. Create the string “i_love_python” and store in variable s.


a. Convert this string into a list called x using list() method.
b. Create another list y without ‘_’ using split() method.
c. Use count() to count the number of ‘o’ in list x.
d. Use count() to count the number of ‘o’ in list y.
e. Use index() to determine the index of ‘love’ in list x.
f. Use index() to determine the index of ‘love’ in list y.
g. Apply join() method on list y to get the string “i_love_python”

8. Solve problems 1 and 2 of problem set 2.

You might also like