Reference no: EM132276375
Lab Activity 5
Lab Activity 5.1
Implement a program that starts by asking the user to enter a login id (i.e., a string). The program then checks whether the id entered by the user is in the list ["joe", "sue", "hani", "sophie"] of valid users. Depending on the outcome, an appropriate message should be printed. Regardless of the outcome, your function should print "Done." Before terminating. Here is an example of a successful login:
>>>
Login: joe
You are in!
Done.
And here is one of that is not:
>>>
Login: john
User unknown
Done.
Lab Activity 5.2
Implement a program that requests from the user a list of words (i.e., strings) and then prints on the screen, on per line all four-letter strings in the list.
>>>
Enter word list: ["stop", "desktop", "top", "post"]
stop
post
Lab Activity 5.3
Write the for loop that will print these sequences of numbers, one per line, in the interactive shell.
(a) Integers from 0 to 9 (i.e., 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
(b) Integers from 0 to 1 (i.e., 0, 1)
Lab Activity 6
Lab Activity 6.1
Write the for loop that will print the following sequences of numbers, one per line.
(a) Integers from 3 up to and including 12
(b) Integers from 0 up to but not including 9, but with a step of 2 instead of the default of 1 (i.e., 0, 2, 4, 6, 8)
(c) Integers from 0 up to but not including 24 with a step of 3
(d) Integers from 3 up to but not including 12 with a step of 5
Lab Activity 6.2
Define, directly in the interactive shell, function perimeter() that takes, as input, the radius of a circle (a nonnegative number) and returns the perimeter of the circle. A sample usage is:
>>>perimeter(1)
6.283185307179586
>>>perimeter(2)
12.566370614359172
Remember that you will need the value of π (defined in module math) to compute the perimeter.
Lab Activity 6.3
Implement function average() that takes two numbers as input and returns the average of the numbers. You should write your implementation in a module you will name average.py.
A sample usage is:
>>> average (1,3)
2.0
>>> average (2, 3.5)
2.75