Ask Programiz - Human Support for Coding Beginners

Explore questions from fellow beginners answered by our human experts. Have some doubts about coding fundamentals? Enroll in our course and get personalized help right within your lessons.

  • All
  • Python
  • C
  • Java
  • CPP
  • SQL
  • JS
  • HTML
  • CSS
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hello Danielle, really nice question.

Any time you use a comparison in Python — things like ==, >, <, >=, and so on — Python evaluates that expression and decides whether it’s true or false. The result of that decision is always a Boolean value: True or False.

For example:

total = 150
result = total > 100
print(result)   # True

Here Python checks the comparison, finds that 150 really is greater than 100, and gives you True. If the comparison wasn’t correct, you’d get False instead.

That’s just how comparisons work in Python:
they always produce a Boolean value.

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

Python
This question was asked as part of the Getting started with Python course.
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hello Rishabh, really nice question.

When you use GROUP BY, you’re asking SQL to take many rows and squeeze them into one row per group. In your case, the groups are countries. That means all customers from the same country get combined so you can calculate something about the whole group — like the average age.

Here’s the key idea:
A grouped result needs one clear value per group.
The country has one value, the average age has one value… but the name does not. There are many customer names in each country, so SQL doesn’t know which one to show.

That’s why this works:

SELECT country, AVG(age) AS average_age
FROM Customers
GROUP BY country;

But adding a name does not make sense unless you also group by it or aggregate it. If you tried:

SELECT country, name, AVG(age)

SQL would ask: “Which name should I show for this country? There are many.”

Once you see it that way, it becomes clear:
GROUP BY is for summaries, not individual details.

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

SQL
This question was asked as part of the Learn SQL Basics course.
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hello Arushi, really nice question.

Both *args and **kwargs let a function take a flexible number of arguments, but they work in different ways.

*args collects positional arguments. These are the values you pass without naming them:

def demo(*args):
    print(args)

demo(1, 2, 3)
# (1, 2, 3)

So args turns into a tuple of whatever positional values you give.

**kwargs collects keyword arguments — the ones you pass using names:

def demo(**kwargs):
    print(kwargs)

demo(name="Arushi", age=20)
# {'name': 'Arushi', 'age': 20}

This becomes a dictionary where the keys are the argument names.

The simple way to remember it:

  • *args → any number of unnamed values

  • **kwargs → any number of named values

They’re both handy when you don’t know ahead of time how many arguments someone will pass into your function.

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

Python
This question was asked as part of the Go beyond Python fundamentals course.
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hello Jay, really nice question.

An int didn’t become 4 bytes by magic — it’s mostly about how modern computers are built. Today’s systems are designed around 32-bit or 64-bit architectures, and a 4-byte (32-bit) integer lines up nicely with how the CPU reads and processes data.

Here’s the idea in simple terms:

  1. Efficiency
    A 32-bit value fits naturally into the CPU’s data pathway, so the processor can read, write, and do math on it quickly.

  2. Standard practice
    Over time, most platforms settled on 4 bytes for int because it balances speed and memory use. It became the “common size” on modern systems.

  3. Range of values
    With 4 bytes, you can represent over four billion different values, which is enough for most everyday programming tasks.

If you run:

cout << sizeof(int);

and see 4, that’s your system telling you the natural size it uses.

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

C++
This question was asked as part of the Learn C++ Basics course.
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hello Akmaral, really nice question.

When you write a countdown loop, you need a condition that tells Python exactly when to stop. Using i > 0 does that perfectly. As long as i is still greater than zero, the loop keeps running. The moment i hits zero, the condition becomes false, and the loop stops.

So if you start at 5 and subtract 1 each time:

i = 5
while i > 0:
    print(i)
    i = i - 1

you’ll get:

5
4
3
2
1

The loop ends right before it would go into negative numbers. It’s simply a clean and safe stopping point.

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

C++
This question was asked as part of the Learn C++ Basics course.
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hello Zade, really nice question.

The reason the function is defined as int instead of void is that it actually produces a value — the sum. Whenever a function calculates something and you want to use that result later in the program, the function needs a return type that matches the kind of value it gives back. In this case, the sum of natural numbers is an integer, so the function returns an int.

A void function is different. It performs an action but doesn’t hand anything back. For example, a function that only prints something to the screen doesn’t need to return a value, so void makes sense there.

So the rule is simple:
If the function gives back a value, choose a matching return type.
If it doesn’t return anything, use void.

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

C
This question was asked as part of the Learn C Programming course.
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hello Anna, really nice question.

*= is just a shortcut for multiplying a variable by something and then storing the new value back into that same variable. It follows the same pattern as +=, which adds to the existing value.

So instead of writing:

x = x * 5

you can write:

x *= 5

Both do exactly the same thing — the second one is just shorter and easier to read once you get used to it.

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

JS
This question was asked as part of the Learn JavaScript Basics course.
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hello David, really nice question.

Yes — absolutely. Every programmer uses Google. Beginners use it, seniors use it, and even the people who build programming languages do it. Coding isn’t about memorizing everything. It’s about knowing what you’re trying to do and finding the right way to do it.

Most of the time you just search for the specific thing you need, like:

  • how to reverse a list

  • how to remove the last element

  • how a certain method works

You read a bit, try it out, and keep going. Over time, the things you look up most often become familiar, and you won’t need to search as much.

So yes — using Google is part of the learning process, not cheating.

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

Python
This question was asked as part of the Getting started with Python course.
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hello An, really nice question.

Yes, in C++ you can assign a default value to a function parameter, just like this:

void find_square(int number = 12) {
    int result = number * number;
    cout << "Square of " << number << " is " << result << endl;
}

Here’s what that means:

  • If you call the function without an argument:

    find_square();    // uses number = 12
    
  • If you call it with an argument:

    find_square(5);   // uses number = 5
    

So C++ will use the value you pass in if you provide one, and if you don’t, it falls back to the default value you wrote in the function definition.

Just remember:

  • This works in C++, not in plain C.

  • Default values are usually written in the function declaration (or definition), not repeated in multiple places.

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

C++
This question was asked as part of the Learn C++ Basics course.
Kelish Rai
Expert
last year
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.