1: duplicate.append(i) print(duplicate) if __name__ == '__main__': arr = [1,2,3,4,2,3,5,6,3] print_duplicates(arr) ``` This program imports Counter from collections module. Counter creates a dictionary with elements of the list as keys and their counts as values. It then iterates through this dictionary and checks if">1: duplicate.append(i) print(duplicate) if __name__ == '__main__': arr = [1,2,3,4,2,3,5,6,3] print_duplicates(arr) ``` This program imports Counter from collections module. Counter creates a dictionary with elements of the list as keys and their counts as values. It then iterates through this dictionary and checks if">
TCS NQT
TCS NQT
TCS NQT
NQT
• The TCS NQT 2020 is attempted by lakhs of
students. The examiners are not going to read
everyone’s code. Instead, they will use a
computerized evaluation which will automatically
assign score based ONLY ON THE OUTPUT.
• Operations on strings
• Number Pattern/number series/pattern printing
• Number Conversion(binary/octal/hexa/decimal)
• Operations on matrices
• Operations on Arrays or numpy
• Operations on numbers (prime no,armstrong
no,palindrome,etc)
Oops
Anonyomus functions(lambda,map,redce,filter)
Checking if a given year is leap year or not
num = int(input("Enter the year you want to check if is leap year or not: "))
if(num%4 == 0):
if(num%100 == 0):
#check if the input year is divisible by 100 and if true move to next loop
if(num%400 == 0):
#the input year is divisible by 4, 100 and 400, hence leap year.
else:
else:
else:
#if the input num is not divisible by 4 then it can not be a leap
year altogether.
Prime Numbers with a Twist
• def prime(n):
if n > 1:
if (n % i) == 0:
break
else:
prime(num)
else:
Nth :15 : 49
Number Series with a Twist – 1
a=0
b=0
for i in range(1,num+1):
if(i%2!=0):
a= a+7
else:
b = b+6
if(num%2!=0):
else: