You can submit this task online or view your submission status if you are a part of this course when you login to WebCMS3.
# Generates a list of 10 random numbers between 0 and 19 included,
# and determines the length of the longest strictly increasing sequence and
# the smallest most frequent element in the list.
#
# Writtten by *** and Eric Martin for COMP9021


import sys
from random import seed, randint


nb_of_elements = 10

try:
     seed(input('Enter an integer: '))
except TypeError:
    print('Incorrect input, giving up.')
    sys.exit()

L = []
for _ in range(nb_of_elements):
    L.append(randint(0, 20))
print('The generated list is:', L)

length_of_longest_increasing_sequence = 1
current_length = 1

smallest_most_frequent = None
largest_count = 0

# REPLACE THIS COMMENT WITH YOUR CODE

print('The length of the longest strictly increasing sequence is: {}'.format(
                                        length_of_longest_increasing_sequence))
print('The smallest most frequent element in the sequence is: {}'.format(
                                                       smallest_most_frequent))
                
    


    
    

Resource created Wednesday 05 August 2015, 11:59:19 PM, last modified Thursday 06 August 2015, 05:21:24 PM.

file: quiz_1.py


Back to top

COMP9021 15s2 (Principles of Programming) is powered by WebCMS3
CRICOS Provider No. 00098G