0 likes • Mar 10, 2021
Python

## More Python Posts

```from collections import Counter
def find_parity_outliers(nums):  return [    x for x in nums    if x % 2 != Counter([n % 2 for n in nums]).most_common()  ]
find_parity_outliers([1, 2, 3, 4, 6]) # [1, 3]```
```prime_lists=[] # a list to store the prime numbers
def prime(n): # define prime numbers    if n <= 1:        return False    # divide n by 2... up to n-1    for i in range(2, n):        if n % i == 0:  # the remainder should'nt be a 0            return False    else:        prime_lists.append(n)        return True

for n in range(30,1000):  # calling function and passing starting point =30 coz we need primes >30    prime(n)
check=0 # a var to limit the output  to 10 onlyfor n in prime_lists:    for x in prime_lists:        val=  n *x        if (val > 1000 ):            check=check +1        if (check <10) :            print("the num is:", val , "=",n , "* ", x )        break```
```# importing the modulesimport osimport shutil
# getting the current working directorysrc_dir = os.getcwd()
# printing current directoryprint(src_dir)
# copying the filesshutil.copyfile('test.txt', 'test.txt.copy2') #copy src to dst
# printing the list of new filesprint(os.listdir())```
```# Python program to reverse a linked list# Time Complexity : O(n)# Space Complexity : O(n) as 'next'#variable is getting created in each loop.
# Node class

class Node:
# Constructor to initialize the node object	def __init__(self, data):		self.data = data		self.next = None

```# Python program for implementation of Selection# Sortimport sysA = [64, 25, 12, 22, 11]
```def when(predicate, when_true):  return lambda x: when_true(x) if predicate(x) else x