Python vs. R
Discover the data science tools and their required level of expertise.
We'll cover the following...
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:
# Program to check if 9 is a prime number or notnum = 9# define a flag variableflag = False# prime numbers are greater than 1if num > 1:# check for factorsfor i in range(2, num):if (num % i) == 0:# if factor is found, set flag to Trueflag = True# break out of loopbreak# check if flag is Trueif flag:print(num, "is not a prime number")else:print(num, "is a prime number")
Here's another example of Python's simplicity:
import scipy.stats as statsdata = [151,153,158,148,153,155,149,151,152,149,147,154]# perform one sample t-testt_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:
# Program to check if 9 is a prime number or notnum = 9flag = 0# prime numbers are greater than 1if(num > 1) {# check for factorsflag = 1for(i in 2:(num-1)) {if ((num %% i) == 0) {flag = 0break}}}if(num == 2) flag = 1if(flag == 1) {print(paste(num,"is a prime number"))} else {print(paste(num,"is not a prime number"))}