Abhay Jajodia's profileExpert

Abhay Jajodia

Answered 166 questions


About

Designer by day, web developer by night, and a full-time tech + gaming nerd in between. I'm always learning, always curious — chasing life's bonus levels, secret achievements, and power-ups like it's one big epic quest.

Answered by Abhay Jajodia
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Good question! The reason we use quotation marks for words (strings) and not for numbers is that quotation marks tell Python that the value inside them should be treated as text, or a string.

For example, when you write `"Python"`, Python knows to treat it as a series of characters, which is a string. On the other hand, writing just `75` without quotes tells Python it's a number, or an integer, which can be used in calculations. So when you're printing or using these values, the quotes help Python distinguish between text and numbers.

Hope this helps! Let me know if you have more questions.

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

To add items to a dictionary, you can use dictionary assignment. Here’s a simple explanation:

Steps to Add Key-Value Pairs to a Dictionary

  1. Create an Empty Dictionary: Start with an empty dictionary using {}.

    my_dict = {}
  2. Define Your Loop: Use a for loop to iterate a set number of times, asking the user for key-value pairs.

    for i in range(3): # This loop will run three times
  3. Get User Input for Key and Value: During each iteration, prompt the user for a key and a value.

    key = input("Enter the key: ") value = input("Enter the value: ")
  4. Add the Key-Value Pair to the Dictionary: Use assignment to add them to the dictionary.

    my_dict[key] = value
  5. Print the Dictionary: Once you’ve added all key-value pairs, print the dictionary to see the result.

    print(my_dict)

Here’s how your code might look after incorporating these elements:

# create an empty dictionary named my_dict
my_dict = {}

# use for loop to iterate and gather user input
for i in range(3):
    key = input("Enter the key: ")
    value = input("Enter the value: ")
    my_dict[key] = value  # add the key-value pair to the dictionary

# print the final dictionary
eprint(my_dict)

I hope this clears things up! Feel free to ask any follow-up questions if you need more clarification. 😊

Python
This question was asked as part of the Practice: Python Basics course.
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hello Hannes! Yes, 4**3 in Python is the same as 4^3 in Excel. This operation is known as exponentiation, which is raising a number to the power of another.

Basically,

4**3 = 4 * 4 * 4 = 64 

Hope this clarifies things for you! Let me know if you have any more questions. Happy coding!

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

Great question — let’s break it down clearly.

Operator precedence decides which operation is performed first in an expression. For example, multiplication and division have higher priority than addition and subtraction. So in this expression:

9 / 3 + 8 * 4 - 2

C++ first evaluates 9 / 3 and 8 * 4, then performs the addition and subtraction.

Associativity decides the direction in which operators are evaluated when they have the same priority. In C++, most arithmetic operators are evaluated from left to right. So in:

3 + 32 - 2

the addition is done before the subtraction.

To make expressions easier to read and control, you can use parentheses, like this:

(9 / 3) + (8 * 4) - 2

This clearly shows which parts are calculated first.

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

Python doesn’t care about singular/plural. languages is the list name, and language is just a variable you chose to store each item one by one, and you can name it anything like item or x. People often use language because it makes the code easier to read.

Example:

languages = ["English", "German", "French"]
for item in languages:
    print(item)

If you have more questions, I am 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

Yes, it changes the meaning a lot. line-height: 1.5; is unitless, so it means 1.5 times the font size, but line-height: 1.5px; forces the line height to be only 1.5 pixels, which is tiny and crushes the text. That’s why lessons usually use the unitless version for readable, scalable spacing.

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

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

Great question. This trips a lot of people up when they first start using Python.

The key thing to remember is that range() stops one number before the value you put in as the second argument. So if you write:

range(1, n)

Python will count like this:

1, 2, 3, ..., n-1

It never reaches n, which is why your loop feels like it’s stopping too early.

If you actually want to include n in the loop, just add 1 to the stop value:

for i in range(1, n + 1):
    total_sum += i

Now Python will count:

1, 2, 3, ..., n

and you get the full sum you expected.

If anything still feels confusing, I’m happy to walk through another example with you.

Python
This question was asked as part of the Practice: Python Basics course.
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hello Varun, really nice question.

A lot of beginners run into this when they start working with functions in C, so you’re definitely on the right track noticing it.

Here’s the simple idea:
If you write a function like this:

int getProduct(float a, float b)

C expects that function to return an int, no matter what you actually calculate inside it. So even if a * b produces a floating-point value, C will convert it to an integer when returning it. That’s why the decimal part disappears.

If you want the full, precise result, you need the function to return a floating-point type:

double getProduct(double a, double b) {
    return a * b;
}

This keeps the decimal values and avoids losing accuracy.

And one more thing students often miss:
You have to actually use the returned value, otherwise it's wasted:

double result = getProduct(3.5, 4.6);
printf("Product: %.2f\n", result);

If anything about return types still feels unclear, feel free to ask — I’m happy to help you understand it fully.

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

Hello Ivan, really nice question.

It’s easy to mix up the idea of a function “returning” with what \n does in a print statement. They sound similar, but they’re completely different things.

When you write:

printf("Hey\nHow are you?");

the \n does not return from the function. It doesn’t stop anything, and it doesn’t exit the print. All it does is tell the output: start a new line here. So the text comes out like this:

Hey
How are you?

The printing continues normally after the newline.
A real return is something you do with a return statement inside a function, not with \n.

If you want more examples or want to see how multiple \n behave, I’m happy to show you.

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

Hello Omar, really nice question.

The logic behind SELECT in SQL is actually pretty simple once you see what problem it solves. A database table is like a giant spreadsheet. Most of the time, you don’t need every single piece of information in that table — you just need certain columns or certain rows.

SELECT is how you tell the database: “Show me only the parts I care about.”

For example, if a table has ten different columns but you only want to see age and country, you can write:

SELECT age, country
FROM Customers;

Now the database gives you just those two columns instead of the whole table. It’s efficient, it’s cleaner, and it makes it easier to work with your data.

So the real logic is:
Ask for the specific data you want instead of taking everything.

If you want to dig deeper into filtering, sorting, or selecting rows, I’m happy to help you explore that next.

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