ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
def is_anagram(a, b):
return sorted(a) == sorted(b)
print(is_anagram('listen', 'silent'), is_anagram('abc', 'abcc'), is_anagram('Aa', 'aa'))- A. True False True
- B. False False False
- C. True True False
- D. True False False
Correct answer: D. True False False
'listen' and 'silent' have the same letters, but the lengths of 'abc' and 'abcc' differ. Sorting is case-sensitive, so 'A' and 'a' are different characters.
More Python Programming questions
- What is printed? python print(pow(3, 1018, 7), pow(3, 6, 7), pow(3, 1018 % 6, 7))
- What is printed? python print(sum(range(10)) / len(range(10)), sum(range(10)) // len(range(10)), sum(range(1, 11)) % 7)
- What is printed? python n = 12345 print(n // 10 3 % 10, n % 10 3 // 100, str(n)[1], n // 1000 % 10 == int(str(n)[1]))
- What is printed? python import math print(math.gcd(240 - 1, 220 - 1) == 220 - 1, math.lcm(12, 18) == 36, math.gcd(1030, 1020) == 1020)
- What is printed? python s = 'racecar level noon python' print([w for w in s.split() if w == w[::-1]], len([w for w in s.split() if w ==…
- What is printed? python s = 'aAbBcC' print(s.lower().count('a') + s.upper().count('A'), s.swapcase(), ''.join(c for c in s if c.islower()))