Thought Game

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”.

why doesn’t my code runs

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.

even if i remove those toph seems to decline my code

Share the latest version then, I will see what is going wrong.

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)

in line 5, use // instead of / , I hope your problem should be solved.
you can see this for better understanding:

@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

#include <stdio.h>

int main() {
int a,b,c;
scanf(“%d %d”,&a,&b);
c=(a+b)/2;
if(c%2==0){
printf(“Oops!”);
}
else{
printf(“Sadia will be happy”);
}
return 0;
}

prb???

c % 2 == 0 means that c is an even number so, you will have to print Sadia will be happy

#include <stdio.h>

int main() {
int t,xi,yi,a,i;
scanf(“%d”,&t);
for(i=0;i<=t;i++)
{
scanf(“%d %d”,&xi,&yi);
a=(xi+yi)/2;
if(a%2==0)
printf(“Sadia will be happy”);
else
printf(“Oops!”);
}
return 0;
}
whats problem?

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’)

Check your output, it should be “Sadia will be happy.”, you missed a full stop which also happened to me.

//where is the problrm??

package Problem_Class_02;

import java.util.Scanner;

public class Q_01 {

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.

A post was split to a new topic: Python Input Help