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 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 Angelica, really nice question.

In Python, both / and // do division, but they don’t give you the same kind of result.

  • / is normal division
    It always gives you a float (a number with a decimal), even when the result is a “whole” value.

    8 / 2   # 4.0
    9 / 2   # 4.5
    
  • // is floor division
    It divides, then rounds down to the nearest whole number, dropping anything after the decimal.

    8 // 2  # 4
    9 // 2  # 4
    

One extra detail that can surprise people: “round down” means toward negative infinity, so with negative numbers:

-9 // 2   # -5   (because -4.5 rounds down to -5)

So the short version is:

  • Use / when you want a regular division result (with decimals).

  • Use // when you want an integer-like result, rounded down.

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 Ernest, really nice question.

In Python, len() is a built-in function that tells you how many items are in something.

You give it an object like a list, string, tuple, etc., and it returns an integer:

languages = ['Python', 'JavaScript', 'C++']
print(len(languages))   # 3

Here, len(languages) is 3 because there are three items in the list.

It works the same way with strings:

word = "Hello"
print(len(word))   # 5

And with an empty list:

items = []
print(len(items))  # 0

So the simple way to remember it:

len(x) gives you “how many things are inside x”.

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

Good question — both approaches will give you the same result: the string "5.5". But there’s a subtle difference in flexibility.

In the first version:

number_str = str(5.5)

You're hardcoding the value 5.5. This works fine, but it's less reusable.

In the second version:

number = 5.5  
number_str = str(number)

You're converting the value stored in the variable number to a string. This makes your code more flexible — if the value of number changes later, you don’t need to update multiple places in your code.

So while both are technically correct, using the variable is generally the better practice.

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

Hi Hao,

No problem — the while loop can be a bit confusing at first, but it’s actually pretty straightforward once you get the pattern.

A while loop runs a block of code over and over as long as a condition is true.

Here’s a simple example:

count = 1

while count <= 3:
    print("I am inside a loop.")
    print("Looping is interesting.")
    count = count + 1

print("OUTSIDE THE LOOP")

What’s happening here:

  1. count starts at 1

  2. The loop checks: is count <= 3?

    • If yes, it runs the code inside the loop

    • Then it increases count by 1

  3. It checks the condition again

  4. Once count becomes 4, the condition is no longer true, and the loop stops

Output:

I am inside a loop.
Looping is interesting.
I am inside a loop.
Looping is interesting.
I am inside a loop.
Looping is interesting.
OUTSIDE THE LOOP

So the loop runs 3 times, and then the program moves on.

The key is: if you forget to update the variable (count = count + 1), the condition might always be true — and the loop would run forever.

Let me know if anything's still unclear — I’m here to help.

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

Hi there! JSON is a common way to format and exchange data, especially when you're working on applications that involve the web, like APIs.

JSON, which stands for JavaScript Object Notation, is a lightweight data interchange format that's easy for humans to read and write, and easy for machines to parse and generate. It consists of data represented as key-value pairs, much like a Python dictionary. Here's a simple example:

{
  "name": "Alice",
  "age": 25,
  "isStudent": false
}

In the above JSON snippet, there's a key for "name" with a value of "Alice", a key for "age" with a numeric value of 25, and "isStudent" with a boolean value of false. JSON is widely used to send data to and from web servers; when a server responds to a request, it might send data formatted like this.

Hope this helps you understand JSON! Feel free to reach out if you want to know more or have other questions.

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

Hi Shawn,

The main difference is in how they’re defined:

  • List → uses square brackets []

    my_list = [1, 2, 3]
    
  • Tuple → uses parentheses ()

    my_tuple = (1, 2, 3)
    

If you're creating a tuple with just one item, you need a comma — otherwise, Python won’t treat it as a tuple:

single_item = (1)     # This is just the number 1  
single_item_tuple = (1,)  # This is a tuple with one item

Lists don’t need a comma for single items, and you can freely change (mutate) them — unlike tuples, which are immutable.

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

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

Hi Amogh,

In Python, the not keyword is a logical operator that flips the value of a condition:

  • not True becomes False

  • not False becomes True

So when you use if not, you're checking if a condition is not true.

Here’s a simple example:

is_raining = True

if not is_raining:
    print("You don't need to bring an umbrella")
else:
    print("Please bring an umbrella")

In this case, is_raining is True, so not is_raining becomes False, and the code inside the else block runs.

In short, if not is used when you want to run code only when a condition is false.

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

Hi Timi,

Good question. It depends on how the function is defined.

Here’s your example:

def greet(message):
    print(message)

greet('Hi', 'Hello')

In this case, the function greet is defined to accept only one argumentmessage. But when you call it with two arguments ('Hi', 'Hello'), Python throws an error:

TypeError: greet() takes 1 positional argument but 2 were given

So actually, it doesn’t return one output — it raises an error because you passed more arguments than expected.

If you want the function to handle multiple messages, you can use *args, like this:

def greet(*messages):
    for message in messages:
        print(message)

greet('Hi', 'Hello')

Output:

Hi  
Hello

Using *messages lets the function accept any number of arguments and print each one.

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

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

Hi Konstantin,

Yes, that condition creates an infinite loop — unless something inside the loop changes n to a negative value.

Let’s break it down:

  • n == 0 is true if n is exactly 0

  • n > 0 is true if n is positive

  • or means the loop will keep running as long as either of those is true

So basically, as long as n is zero or positive, the condition stays true, and the loop won’t stop. That makes it infinite — unless you manually change n inside the loop to something negative.

If your goal is to loop only while n is positive (and stop on zero or anything less), just write:

while n > 0:

Here’s a quick example:

n = float(input())
total = 0

while n > 0:
    total += n
    n = float(input())

print(total)

This will keep adding numbers until the user enters zero or a negative value.

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

Python
This question was asked as part of the Getting started with Python course.