Python vs. R

Discover the data science tools and their required level of expertise.

Python is a free and open-source programming language that can run on operating systems such as Windows, Linux, Unix, and macOS. You can use it for data analysis, visualization, website development, software development, automation, and so on. The most attractive thing is its syntax, which imitates the natural language we humans speak, as shown in the examples below:

Press + to interact
# Program to check if 9 is a prime number or not
num = 9
# define a flag variable
flag = False
# prime numbers are greater than 1
if num > 1:
# check for factors
for i in range(2, num):
if (num % i) == 0:
# if factor is found, set flag to True
flag = True
# break out of loop
break
# check if flag is True
if flag:
print(num, "is not a prime number")
else:
print(num, "is a prime number")

Here's another example of Python's simplicity:

Press + to interact
import scipy.stats as stats
data = [151,153,158,148,153,155,149,151,152,149,147,154]
# perform one sample t-test
t_statistic, p_value = stats.ttest_1samp(a=data, popmean=150)
print(t_statistic , p_value)

R is a free and open-source programming language that can run on operating systems such as Windows, Linux, Unix, and macOS. You can use it for data analysis and visualization. The most attractive thing about R is how easy it is to perform statistical computing, as shown in the examples below:

Press + to interact
# Program to check if 9 is a prime number or not
num = 9
flag = 0
# prime numbers are greater than 1
if(num > 1) {
# check for factors
flag = 1
for(i in 2:(num-1)) {
if ((num %% i) == 0) {
flag = 0
break
}
}
}
if(num == 2) flag = 1
if(flag == 1) {
print(paste(num,"is a prime number"))
} else {
print(paste(num,"is not a prime number"))
}
...