Task: One of the latest and most rapidly growing fields of
science is Data Science. Data Science is an interdisciplinary field
that uses programming and statistics to create insights into (big)
data. With more and more data being readily available to scientists
and companies, effective data science is becoming increasingly
important for both scientific and commercial purposes. Social media
businesses revolve around data science and essentially let their
users “pay” with their data. Python is a very useful programming
language for data scientists. In this assignment, you will use
Python to do some very basic data analysis. You will extract two of
the most common characteristics of a list of integers: the maximum
and the minimum. For this task, you will use the python while-loop
to repeatedly ask the user for integer input until the user writes
any other non-integer input (e.g. “stop” or leave input empty). All
the integers that the user inputs are the data set you will work
with. Inside this loop, you will update the three characteristics
of this list of integers in real time, that means you will do these
things in the loop:
● Ask for a new number;
● Check if the number is numeric;
● Check if the number is larger than the current maximum
number;
● Check if the number is smaller than the current minimum
number;
● If the number is not numeric: break out of the loop with the
break keyword. After finishing (because the user gave a non-integer
input), your script should print the maximum and minimum in that
order. Write this in a script called data_analyzer.py. Use a string
function to check if the input is integer. You do not have to
implement any other input validation, as any incorrect input should
result in the while-loop, and thus your script, finishing and
providing the results. You may want to use the while-loop in
combination with python’s break statement, which breaks out of the
loop (read more here). Also, do not forget to cast the user’s input
to integers (using int()) after checking that it actually is an
integer.
Example usage: $ python3 data_analyzer.py
Input: 10
Input: 9
Input: 8
Input: 7
Input: 6
Input: 5
Input: 4
Input: 3
Input: 2
Input: 1
Input: stop
Maximum: 10
Minimum: 1
$ python3 data_analyzer.py
Input: 5
Input: 5
Input: stop
Maximum: 5
Minimum: 5
$ python3 data_analyzer.py
Input: No integer given.
Task: One of the latest and most rapidly growing fields of science is Data Science. Data Science is an interdisciplinary
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am