Over a million students use our free study notes to help them with their homework
def s(n): ans=[] #This variable stores the list we will return. for i in range(n): #This is a for loop that will iterate n times. ans.append((i+1)**2) #This adds the (i+1)th square to the list, because ra...
The main differences between the two boil down to the difference between greedy and lazy evaluation. With a list, each indexed object takes up some space in memory. Range, however, calcu...
Systems programming e.g. searching for files, launching other programs etc (sometimes called shell tools)GUI’s -tkinterInternet Scripting – web scraping (getting information from websites so you can use i...
A simple solution to this problem would be as follows [x for x in list[::2] if x%2 == 0] For example, given the following list: list = [ 1 , 3 , 5 , 8 , 10 , 13 , 18 , 36 , 78 ] The list comprehension [x ...
def factorial(n): fact = 1 for i in range(2,n+1): fact*=i; return factx=input("Enter a number :")print("The factorial of "+x+" is "+factorial(x))
←
2
3
4
5
6
→
Internet Safety
Payment Security
Cyber
Essentials