Question Set 1
Question Set 1
Q2.
a) Perform the following:3+4*(5^2-9) and assign the result to a new variable and
display its value
b) Assign 4 to x and 7 to y. Test x and y for the following operators: ==, !=, >, >=,
<=
c) Check the conditions 2>3 and 3<4 by using the operators & and |
d) Enter a comment line “ All exercise completed” in a R-script
e) Save your script
Q3.
Q4.
Q5.
Q6. Create two vectors of same length. Apply all arithmetic operations on this two and display the
result in each case
Q7.
a) Create a list with the First name of four members of your family, their age,
Surname. Use Surname “Gupta” for all members
b) Check the data type using str()
c) Access the name and age from the list
d) Change the surname to “Sharma”
Q8.
Q9.
x + 2y = 4
x-y=1
Q10. Create an array that consists of 3 matrices of size 1X2 with the elements as”RED” and “BLUE”
Q11.
Q12.
a) create a data frame with the 5 observations consisting of variables : Name, Age,
Educational qualification, year of experience, monthly salary earned.
b) Display top 5 observations
c) Display bottom 5 observations
d) Use display data with a condition
e) Now add a row to the data frame
f) Add a column to the data frame by specifying its name as “Revised_Salary” and
compute the Revised Salary with a 40% hike
g) Relocate the column after monthly salary earned
Q13.
Q14.
Q15. A patient is taking the first dose of a medicine on 15 th May 2023. He has to take this medicine
on the 15th day of every moth for next 6 months. Help the patient by displaying all the dates he has
to take medicine.
Q16. Write the command for displaying the present system’s time and format it as HH:MM:SS
Q17.
a) Take an integer and check if it is even. Print” the number is even” if it is even.
b) Take an integer and check if it is even. Print” the number is even” if the condition
is satisfied or “the number is odd” if not satisfied.
c) Enter a number and check it is a two-digit number and print your result statement
d) Enter a string and check if a particular word belongs to that string.
e) Access the present system time, and print a “Good Morning”/”Good afternoon” or
“Good Evening” message accordingly
a) Find the sum and average of first 10 natural numbers using for loop
b) Find the sum of first 10 odd numbers
c) Find the sum of the squares of first
d) 10 natural numbers.
e) Print the following pattern:
*
**
***
****
*****
Q19. A man has Rs. 15000 in his account. He is spending Rs. 2875 on a recurrent basis from his
account. A minimum balance of Rs. 5000 must be maintained in the account to keep it active.
Assuming that there is no amount credited to his account during this period, write a code in R to
determine how many transactions he will be able to make and what how much would be remaining
in his account after the last transaction, also print the balance after every transaction and display a
message “Amount not sufficient” when the balance is less than minimum .
Q20.
b) Write a function to compute the total amount of a person, taking the principal and
rate of interest as user input
c) Write a function to compute profit where the quantity purchased, cost of each item
and the selling price of each item is given by the user.
d) Write a function that points the grade of the students according to the obtained
marks:
Less than 40: Fail
Greater than or equal to 40 but less than 60: C
Greater than or equal to 60 but less than 80:B
Greater than or equal to 80 : A
e) Write a script that points the grade of a group of students according to the obtained
marks:
Less than 40: Fail
Greater than or equal to 40 but less than 60: C
Greater than or equal to 60 but less than 80:B
Greater than or equal to 80 : A
f) Create a function that finds out the greatest number among the three given numbers
h) Write a function to take two numbers from the user and check if the first one is a
factor of the second one.