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

New Text Document

The document contains 5 questions and code snippets. Question 1 generates random passwords, Question 2 is blank, Question 3 analyzes a list of numbers to find minimum, maximum, average, even and odd counts, Question 4 is blank, and Question 5 is blank.

Uploaded by

sharifah iman
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)
26 views2 pages

New Text Document

The document contains 5 questions and code snippets. Question 1 generates random passwords, Question 2 is blank, Question 3 analyzes a list of numbers to find minimum, maximum, average, even and odd counts, Question 4 is blank, and Question 5 is blank.

Uploaded by

sharifah iman
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

Q1

CODE

import random

s1 = 'abcdefghijklmnopqrstuvwxyz'
s2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
s3 = '0123456789'
s4 = '@#$'
s = s1 + s2 + s3 + s4

print('Passwords: ')

for i in range (5):


pwd = ' '
for i in range (8):
pwd = pwd + random.choice(s)
print('Password', i+1, ': ', pwd)

Q2

CODE

Q3

CODE

x = [11, 22, 13, 44, 5, 6, 19, 99, 66, 37]


n = len(x)
min = x[0]
max = x[0]
sum = 0
even = 0
odd = 0

for i in range (n):


if min > x[i]:
min = x[i]
if max < x[i]:
max = x[i]
if n%2 != 0:
odd = odd + 1
else:
even = even + 1
sum = sum + x[i]
avg = sum / n

print('\nminimum: ', min)


print('\nmaximum: ', max)
print('\naverage: ', round (avg, 2))
print('\neven: ', even)
print('\nodd: ', odd)

Q4

CODE
Q5

CODE

You might also like