For the last couple of days, I am observing the question pattern in TCS. I would like to share some tricks and tips to crack the question in less time.
I hereby declare that these shots are only helpful for some type of questions in the Exam.
As of now Quick Shots
are available in only Python Programming Language.
Good to Know
### Quick Inputs
name = raw_input() # for Strings
number = int(input()) # for Integers
Yes or No Questions
def yes_or_no():
reply = str(raw_input('(y/n):')).lower().strip()
if reply[0] == 'y':
return True
if reply[0] == 'n':
return False
else:
return None
isMember = yes_or_no()
if(isMember == None):
print("Invalid Input")
Accepting Values in Same line (with Spaces)
values = [int(x) for x in raw_input().split()]
print(values)
# input: 1 2 3 4
# output: [1, 2, 3, 4]
Accepting Values in Same line (with Commas)
values = [int(x) for x in raw_input().split(', ')]
print(values)
# input: 1, 2, 3, 4
# output: [1, 2, 3, 4]
Percentage Questions
# 85% of 2043.43
def percentage(part, whole):
return (part * whole)/100
print(percentage(85,2043.43))
# output: 1736.9155
Invalid Input
INVALID INPUT
Note: Input and Output should be formatted as given for the example.
For any wrong value input display “INVALID INPUT”
def inv():
print("INVALID INPUT")
inv()
# This helps you in code reusability
# avoid this if have one possibility
Float decimal value after a point
value = 3282.2548
print("%.f"%value) # 3282
print("%.1f"%value) # 3282.3
print("%.2f"%value) # 3282.25
Stay Tuned
If you like to improve your App Development Skills, even more in Flutter and SwiftUI. Feel free to dm me on Instagram or tweet to me on Twitter if you have any additional tips or feedback.
Thanks for reading!
Top comments (2)
Good
Thanks of lot:D