0% found this document useful (0 votes)
11 views1 page

R and Pythonn Lab

Uploaded by

vijay the stark
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

R and Pythonn Lab

Uploaded by

vijay the stark
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

R and Python Lab Assessment

R Programming

Q1. Consider the mtcars data set which is available in R.


 How many observations and variables are available?
 Print the hp variable using the select() function.
 Provide the frequency distribution (absolute, relative and percentage) for the
am variable (transmission).
 Select all the observations which have mpg>20 and hp>100 and compute the
average for the mpg variable.
 Compute the distribution (absolute frequencies) of the car by gear. Moreover,
compute the mean consumption (mpg) conditionally on the gear.

Q2. Define a function named mypower to print a number raise to another. The two
numbers are the arguments of the function and the exponent number is set by
default equal to one. Compute using mypower the following quantities:

2 , 𝑒𝑥𝑝(4) , log(45)
Is it possible to provide a vector of exponents as input to the mypower function
(while the base doesn’t change)? If yes, provide an example.

Python

Question 1.
a) Write a program to remove duplicates in a string.
b) Write a python function to print the factorial of a number using recursion

Question 2.
Create a Python class called BankAccount which represents a bank account,
having as attributes: accountNumber (numeric type), name (name of the account
owner as string type), balance.

a) Create a constructor with parameters: accountNumber, name, balance.


b) Create a Deposit() method which manages the deposit actions.
c) Create a Withdrawal() method which manages withdrawals actions.
d) Create an bankFees() method to apply the bank fees with a percentage of 5%
of the balance account.
e) Create a display() method to display account details.
f) Write the complete code for the BankAccount class.

You might also like