-
Notifications
You must be signed in to change notification settings - Fork 0
/
group_work_wk3.py
73 lines (63 loc) · 3.01 KB
/
group_work_wk3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Choose any of the problems below; if you finish one, try to do the
# "challenge" part of the problem or choose another to try!
# 1
# Create a program that contains dictionaries for each person in
# your group, and call the dictionaries "person_1", "person_2", etc..
# Use the same "key :value" pairs in each dictionary.
# One "key : value" pair should identify a person somehow,
# and the rest should describe other attributes of a person.
# Finally, print all of the dictionaries
# 2
# Create a program which defines the function "fun_with_modulo". This
# program should take an int x as its argument and print one of four
# strings of your choice depending on the modulus of x with 4 (i.e x modulo 4, or
# the integer remainder when x is divided by 4).
#
# Challenge:
# Import this program as a module into another program
# which takes integer user input and feeds it to the "fun_with_modulo" function
# Extra: Use exceptions to handle non-integer number input
# 3
# Create a program which defines the function "fun_with_e" which
# takes as its argument a positive number x and returns e^x + ln(x).
# Define a positive number x with user input or by hardcoding it,
# and print the ouput of fun_with_e(x)
#
# Challenge:
# Import this program as a module into another program
# which takes integer user input and feeds it to the module function
# Extra: Use exceptions to handle non-positive number input
# 4
# Create a program which defines a function "more_fun_with_e" which takes as its argument
# a 4-element array "arr1" and creates a new array "arr2" in which,
# for each element x in "arr1", "arr2" has a corresponding element
# whose values is e^x + ln(x).
# Define a 4-element array of positive floats "arr1" with user input or by hardcoding it,
# and print arr1 and the output of more_fun_with_e(arr2)
#
# Challenge:
# Import this program as a module in another program
# which takes positive number user input to create a 4-element array and
# then and passes this array to "more_fun_with_e" as an argument.
# Print the input array and the output array.
# Extra: Use exceptions to handle non-positive number input
# 5
# Create a program that defines a function "num_digits" that takes an integer
# as its argument and returns the number of digits of the number. Define an integer
# within your program to test your code.
# Hints are available, this one might be more math-y!!
#
# Challenge:
# Import this program as a module in another program
# which takes integer user input and feeds it to the module function.
# Extra: Use exceptions to handle non-integer input
# 6 (tricky problem!)
# Create a program that defines a function "primes" which takes a positive integer as its
# argument and prints out all of the prime numbers of value less than or equal
# to the input integer.
# Hints are available, this one might be more math-y!!
#
# Challenge:
# Import this program as a module in another program
# which takes integer user input and feeds it to the module function.
# Extra: Use exceptions to handle non-positive non-integer input