ANLY Aishwarya Assignment 3
ANLY Aishwarya Assignment 3
Assignment 3:
Advance programming inn Data Analytics
ANLY 560-90-0
Student: Aishwarya Reddy
2
Module:
One Python file that includes variables, classes, and methods that can be imported and utilized
by other Python scripts is called a module. For instance, the module random.py has routines for
Example:
math_utils.py
Package:
A group of many modules arranged in a directory with a __init__.py file is called a package. The
package may be seen as a module in and of itself thanks to the __init__.py file. For instance, the
Example:
mypackage/
├── __init__.py
├── module1.py
├── module2.py
3
Libraries:
A library is an assortment of packages and modules that offer a variety of features. Libraries may
have several packages with different functions. For instance, the package Pandas contains
Q2:
Python task
Write a Python script that imports the random module.
import random
random_value = random.random()
print(random_value)
Use the random.randint() function to generate and print 10 random integers between 1 and
100.
import random
for _ in range(10):
random_number = random.randint(1, 100)
print( random_number)
4
output:
66
53
33
23
33
49
78
24
70
80
Use the random.choice() function to randomly select an element from a list [‘apple’,
import random
fruits = ['apple', 'banana', 'cherry', 'date', 'elderberry']
selected_fruit = random.choice(fruits)
print(selected_fruit)
output:
apple
5
R Task:
1.
%load_ext rpy2.ipython
2.
##Install the package
%%R
install.packages("ggplot2")
3.
#2. Load the packages --> similar to the import statement in python
4.
#3. Use the functions and methods from the package as built-in functions
5.
%%R
str(quakes)
6.
# %% [code]
Installment of dplyr
7.
%%R
library(dplyr)
6
8.
%%R
output:
ID Score
1 5 100
2 10 84
3 9 78
4 7 77
5 3 76
6 6 76
7 2 75
8 1 74
9 8 58
10 4 54