Posts

Showing posts from 2019

Looping in R

Image
LOOPS in R Loops are part of iterative programming where the user wants to perform a sequence of instructions N number of times. R provides 3 styles of loops: For Loop While Loop Repeat Loop For Loop For loops are used when we want to iterate over a sequence like vectors and or data frames. Syntax: v<-c(10,21,11,31,88,78) for (i in v){       print(i) } This will iterate over all the elements of vector v. For iterating over individual elements using the index one can use sequence vector and use it as index. Syntax: v<-c(10,21,11,31,88,78) for (i  in  1:length(v)){       print(v[i]) } While Loop While loops are used when the iterations depend on a condition and it is difficult to predict the number of iterations. SYNTAX: i<-2 while(i<=10){          print(i)          i<-i+2 } Repeat Repeat is a new construct available only in R to run an infinite loop. Repeat block will iterate until a

Python Interview Questions

Hi Readers, Writing the post after a long time, was looking out for job opportunities. Facing around 10-15 interviews, I have experienced some of the common interview questions asked from a Python Developer and thought of creating a list of these questions. Will create a  separate post for answers as well. Here is the list of interview questions for python interviews: Which version of python have you worked with? What are MAGIC methods? What are DECORATORS? Write a decorator to add a '$' sign to a number. What are the different data types in python? What are mutable and immutable data types? Difference between list and tuples? Which one is faster to access list or a tuple and why? What is list comprehension? What is the use of negative indexing in the list? Why do we need list comprehension? How is it different from creating a list using a loop What are SETS in python? How are they different from LISTS? How SETS are internally stored in python? Which dat