Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
30 views3 pages

Python Week4 16MSS017

The document contains 5 Python programs: 1) an infinite loop that prints a value, 2) a factorial program, 3) a program to print string values in a list using iter(), 4) a program to find max and min of a list using built-in functions, 5) a program to reverse a list using the reverse() function. Each program is presented with the code, expected output, and a brief description.

Uploaded by

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

Python Week4 16MSS017

The document contains 5 Python programs: 1) an infinite loop that prints a value, 2) a factorial program, 3) a program to print string values in a list using iter(), 4) a program to find max and min of a list using built-in functions, 5) a program to reverse a list using the reverse() function. Each program is presented with the code, expected output, and a brief description.

Uploaded by

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

PYTHON WEEK4 ASSESSMENT

1. Write a program for infinite loop


PROGRAM:
a=10
while a==10:
print(a)
OUTPUT:

2. Write a program to find the factorial of a number


PROGRAM:
num = int(input("Enter a number:"))
fact = 1
if num < 0:
print("Negative numbers are not included")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
fact = fact*i
print("The factorial of",num,"is",fact)
OUTPUT:

3. Write a program to print the string values stored in a list using iter()
function
PROGRAM:
list=[‘a’,’b’,’c’,’d’]
for i in iter(list):
print(i)
OUTPUT:
4. Write a program to print maximum and minimum values from a list
using built in functions
PROGRAM:
list=[1,4,60,50,32,41,76]
print("The maximum number is:",max(list))
print("The minimum number is:",min(list))
OUTPUT:

5. Write a program to reverse a list of values using built in functions


PROGRAM:
list=[8,17,2,3,7,0,'a','b','k','m']
print("Original list:",list)
list.reverse()
print("Reversed list:",list)
OUTPUT:

You might also like