Sadia is one of the nicest persons you will ever meet. In fact, she is one of those persons who like…
Click here to read the complete problem statement.
If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.
test_cases = int(input("Number of test cases"))
for i in range(test_cases):
a = int(input("Give a number: "))
b = int(input("Give another number: "))
c = (a+b)/2
if c%2 == 0:
print("Sadia will be happy.")
else:
print("Oops!")
NoBody told you to print “Number of test cases” or "Give a number: " or "Give another number: "
Your output format should be in the way that is expected in the problem statement.
Just remove those strings from the input() function and your code should be accepted.
test_cases = int(input())
d = []
for i in range(test_cases):
a, b = map(int, input().split())
c = (a + b) / 2
if c % 2 == 0:
d.append(“Sadia will be happy.”)
else:
d.append(“Oops!”)
for i in d:
print(i)
@Abdullah_1234
at least try to implement what I told you before asking in the community.
I have tried submitting your code using // operator and it works.
You have no reason for getting Runtime Error
Why you use for loop here?
Solusion is :
num_1 = int(input(‘enter number 1’))
num_2 = int(input(‘enter number 2’))
if num_1 + num_2 % 2 == 0:
print('samia will be happy ')
else:
print(‘oops’)
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n, c = 0, d = 0, k = 0, avg;
System.out.print("Enter How many times you wanna Check(1 to 10) : ");
n = input.nextInt();
if (n >= 1 && n <= 10) {
int[][] num = new int[n][n];
//taking value
for (int i = 0; i < n; i++) {
System.out.println("Enter your 2 number for row " + (i + 1) + " : ");
c = 0;
k = 0;
for (int j = 0; j < 2; j++) {
num[i][j] = input.nextInt();
if (num[i][j] >= 1 && num[i][j] <= 100) {
k = k + num[i][j];
} else {
d++;
}
}
avg = k / 2;
if (avg % 2 == 0) {
c++;
}
if (d > 0) {
System.out.println("Print valid number");
break;
} else if (c == 1) {
System.out.println("Sadia Will be Happy");
} else {
System.out.println("Opps!");
}
}
} else {
System.out.println("Print valid number");
}
}
Just print the desired output. Nothing more or nothing less. Dont print anything unnecessary and you need to print a new line after each time you print anything. New solvers often get into this situation.