Complete_Python_Questions_with_Answers
Complete_Python_Questions_with_Answers
Which of the following is the correct way to open a file in Python for reading?
a) open("file.txt", "r")
b) open("file.txt", "w")
c) open("file.txt", "rb")
d) open("file.txt", "rw")
Answer: a) open("file.txt", "r")
Which operator is used to check if two values are not equal in Python?
a) !=
b) <>
c) =!
d) None of the above
Answer: a) !=
4. What function would you use to read data from a CSV file in R?
a) load()
b) read.csv()
c) import()
d) read.table()
Answer: b) read.csv()
11. Which function is used to find the maximum value in a numeric vector?
a) max()
b) min()
c) largest()
d) biggest()
Answer: a) max()
15. Which function in R is used to return the first few rows of a data frame?
a) head()
b) tail()
c) first()
d) top()
Answer: a) head()
21. Which function in R can be used to join two data frames by a common column?
a) merge()
b) combine()
c) concat()
d) join()
Answer: a) merge()
29. Which of the following is used to display the last few elements of a vector in
R?
a) head()
b) tail()
c) end()
d) last()
Answer: b) tail()
31. How can you get the number of columns in a data frame?
a) ncol()
b) length()
c) count()
d) colCount()
Answer: a) ncol()
47. Which of the following will return the last 6 rows of a data frame?
a) head(df)
b) tail(df)
c) last(df)
d) end(df)
Answer: b) tail(df)
48. What is the function for calculating the quantiles of a numeric vector in R?
a) quantile()
b) percentile()
c) quant()
d) range()
Answer: a) quantile()