Kelish Rai's profileExpert

Kelish Rai

Technical Content Writer @Programiz

Answered 90 questions


About

Hi, I'm Kelish, Technical Content Writer at Programiz. I break down complex programming concepts and turn them into easy-to-understand articles, tutorials, and courses. I'm also a developer at heart—I love solving coding problems, exploring algorithms, and staying updated with the latest tech stuff. If I'm not writing content, there's a good chance I'm working on a side project.

Answered by Kelish Rai
Kelish Rai
Expert
last month
Kelish Rai answered

Hello OTM Egytrans, really nice question.

In SQL, DISTINCT doesn’t belong to just one column once you write it — it applies to the entire set of selected columns together.

So:

SELECT DISTINCT col1
FROM your_table;

gives you unique values of col1.

But:

SELECT DISTINCT col1, col2
FROM your_table;

now treats each (col1, col2) pair as a single combination. SQL removes duplicate rows where both col1 and col2 are the same. It does not make col1 distinct while allowing col2 to vary freely in that same query.

That means there’s no direct way to say “make column 1 distinct, but don’t apply DISTINCT to column 2” in one simple SELECT DISTINCT col1, col2 statement.

If you want “distinct by column 1” and still show something from column 2, you usually:

  • either decide which row per col1 you want (for example, with MIN(col2) or MAX(col2) plus GROUP BY col1), or

  • use more advanced techniques (like window functions) depending on your database.

But the key idea is:
DISTINCT always works on the whole selected row, not just a single column unless you only select that one.

If you have further questions, I'm here to help.

SQL
This question was asked as part of the Learn SQL Basics course.
Kelish Rai
Expert
last month
Kelish Rai answered

Hi Jayadithya,

Great question — this trips up a lot of learners.

The sizeof() operator does return the correct value — it gives you the size of a type or variable in bytes. But here’s the key part:
printf() doesn’t know what type you're printing unless you tell it using a format specifier.

So even if sizeof(int) returns a valid number like 4, you still need to use %d or %lu (depending on your system and compiler) to tell printf how to interpret and display that value.

Now, about using different format specifiers — yes, that’s sometimes intentional. For example:

char ch = 'A';
printf("%d", ch);  // Prints 65 instead of 'A'

Here, %d is used to show the numeric (ASCII) value of the character, not the character itself.

So to sum up:

  • sizeof() works fine — the issue is with how you choose to print the result.

  • Sometimes, using a "wrong" format specifier is done on purpose to view data differently.

If you have more questions, I am here to help.

C
This question was asked as part of the Learn C Programming course.
Kelish Rai
Expert
last month
Kelish Rai answered

Hi quiet,

You're absolutely right .

In Java, Math.random() returns a value from 0.0 (inclusive) to 1.0 (exclusive). So:

Math.random() * 10    // gives a value from 0.0 to less than 10.0  
Math.random() * 10 + 1  // gives a value from 1.0 to less than 11.0

So the correct range for Math.random() * 10 + 1 is 1.0 (inclusive) to less than 11.0 (exclusive).

If you have more questions, I am here to help.

Java
This question was asked as part of the Learn Java Basics course.
Kelish Rai
Expert
last month
Kelish Rai answered

In C, when you use a comparison like total > 100, it doesn’t return true or false as words — it returns a number:

  • 1 if the condition is true

  • 0 if it’s false

So if you write:

result = total > 100;

C checks if total is greater than 100. If it is, result becomes 1. If not, result becomes 0.

That’s why the output is either 0 or 1 — it's just how C handles boolean logic under the hood.

If you have more questions, I am here to help.

C
This question was asked as part of the Learn C Programming course.
Chika Lucinda Barn-Nzekwe
2 months ago
Chikacountry asked
Kelish Rai
Expert
last month
Kelish Rai answered

Hi Chika,

int stands for integer, which means whole numbers — no decimals. Examples include 5, 42, or -100.

In most programming languages, including C and C++, int is used to declare variables that store whole numbers:

int age = 25;

That line creates a variable named age that holds the value 25.

If you have more questions, I am here to help.

SQL
This question was asked as part of the Learn SQL Basics course.
Kelish Rai
Expert
last month
Kelish Rai answered

Hi Charan,

You can use both in Python, but a single string must start and end with the same type of quote.

These are fine:

text1 = "Hello"
text2 = 'Hello'

You can mix them inside the string to avoid escaping:

msg1 = "It's a sunny day"
msg2 = 'She said, "Keep learning."'

But this is not valid because the quotes do not match:

text = "Hello'

If you have more questions, I am here to help 😊

Python
This question was asked as part of the Learn Python Basics course.
ملیکا عفوی
6 months ago
ملیکاcountry asked
Kelish Rai
Expert
6 months ago
Kelish Rai answered

Yes, you can use Python to build apps, but how commonly it’s used depends on the type of app.

Python is really popular for web apps. A lot of websites and web services use Python behind the scenes, especially with frameworks like Django and Flask. So if you're interested in building web-based projects, Python is a great choice.

For desktop apps or mobile apps, Python is less commonly used. There are tools like Tkinter (for desktop apps) or Kivy and BeeWare (for mobile apps), but most developers usually prefer other languages like Swift for iOS, Kotlin for Android, or JavaScript frameworks for cross-platform apps because they offer more native features and smoother performance.

That said, Python is still great for learning app development concepts, automating tasks, building quick tools, and working on web projects.

If you’d like help getting started or if anything from the course needs clarification, just let me know. I’m happy to help.

Python
This question was asked as part of the Learn Python Basics course.
Kelish Rai
Expert
last year
Kelish Rai answered

Simply put,

  • Memory location refers to a specific spot in the computer’s memory where data is stored. Think of it as a unique address where your data lives while your program is running. Every variable in your program is stored in one of these memory locations.

  • Data type is about the kind of data that goes into a memory location. For example, if you’re storing a number, the data type could be an int (integer) or a float (decimal number). If you’re storing text, the data type would be char or string.

So, in simple terms: Memory location is where data lives, and data type is what kind of data it is.

It’s okay if it's not 100% clear right now. As you continue with the course, this concept will make more sense.

Let me know if you need help with anything else.

C
This question was asked as part of the Learn C Programming course.
Ritika Gangwar
last year
Ritikacountry asked
Kelish Rai
Expert
last year
Kelish Rai answered

In programming, input simply means getting information from the user.

As you progress through the course, you'll learn how to take input in Python and use it in your programs.

Let me know if anything is unclear or if you'd like to explore this further.

Python
This question was asked as part of the Learn Python Basics course.
Kelish Rai
Expert
last year
Kelish Rai answered

Yes, console.log() in JavaScript is similar to print() in Python — both are used to display information to the console or terminal.

JS
This question was asked as part of the Learn JavaScript Basics course.