0
0
R Programmingprogramming~20 mins

R vs Python for data analysis in R Programming - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Data Science Language Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of data frame summary in R
What is the output of the following R code snippet?
R Programming
df <- data.frame(age = c(25, 30, 35, 40, 45), score = c(88, 92, 95, 85, 90))
summary(df)
A
age: 25 30 35 40 45
score: 88 92 95 85 90
B
age  score
25   88
30   92
35   95
40   85
45   90
CError in summary(df): object 'df' not found
D
      age           score     
 Min.   :25.00   Min.   :85.00  
 1st Qu.:30.00   1st Qu.:88.00  
 Median :35.00   Median :90.00  
 Mean   :35.00   Mean   :90.00  
 3rd Qu.:40.00   3rd Qu.:92.00  
 Max.   :45.00   Max.   :95.00  
Attempts:
2 left
💡 Hint
summary() in R gives statistical summaries for each column in a data frame.
🧠 Conceptual
intermediate
2:00remaining
Key difference in data handling between R and Python
Which statement best describes a key difference in how R and Python handle data analysis?
AR primarily uses data frames as a native data structure, while Python uses lists only.
BR has built-in support for statistical models, while Python requires external libraries for similar tasks.
CPython's pandas library provides data frames similar to R, but R's data frames are more integrated into the language.
DPython cannot handle large datasets efficiently, unlike R.
Attempts:
2 left
💡 Hint
Think about how each language treats data frames and libraries.
🔧 Debug
advanced
2:00remaining
Identify the error in R code for reading CSV
What error will this R code produce?
R Programming
data <- read.csv('datafile.csv', header=FALSE, sep=';')
head(data)
AError: cannot open file 'datafile.csv': No such file or directory
BError: unexpected symbol in 'read.csv('datafile.csv', header=FALSE, sep=';')'
CNo error, outputs first 6 rows of data
DError: unused argument (sep = ';')
Attempts:
2 left
💡 Hint
Check if the file exists in the working directory.
data_output
advanced
2:00remaining
Output of Python pandas groupby aggregation
What is the output of this Python code using pandas?
R Programming
import pandas as pd

df = pd.DataFrame({'team': ['A', 'A', 'B', 'B'], 'points': [10, 15, 10, 5]})
result = df.groupby('team').sum()
print(result)
A
      points
team         
A         25
B         15
B
team  points
A     10
A     15
B     10
B     5
C
points
A  10
B  5
DError: 'groupby' is not a function
Attempts:
2 left
💡 Hint
groupby sums points for each team.
🚀 Application
expert
3:00remaining
Choosing between R and Python for a project
You have a project requiring advanced statistical modeling and interactive visualizations. Which choice is best and why?
AUse R because Python lacks libraries for data visualization.
BUse R because it has strong statistical packages and interactive visualization libraries like Shiny.
CUse Python because R cannot create interactive visualizations.
DUse Python because it has better support for statistical modeling than R.
Attempts:
2 left
💡 Hint
Consider the strengths of each language in statistics and visualization.