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
A
Expert
last month
Abhay Jajodia answered

So, in Python, you don't need to use curly braces {} when printing a variable like this:

name = input("Enter your name: ")
print("Your name is", name)
    

That works because print() can take multiple things, separated by commas. It just puts spaces between them automatically, so you don't have to do anything fancy.

Now, curly braces do show up when you're using something like an f-string. That looks like this:

print(f"Your name is {name}")
    

In that case, the {name} is inside the string, and Python replaces it with the actual value of the name variable — but only because the string starts with an f.

So yeah, curly braces are just for special formatting stuff like f-strings. If you're just printing normally with commas, you don’t need them at all.

Python
This question was asked as part of the Learn Python Basics course.
Aarjvi Parekh
PRO
last month
Aarjvicountry asked
Palistha Singh
Expert
last month

Whitespaces are just empty spaces in your text.

For example:

text = "  Hello  "

This has extra spaces before and after Hello.

Those extra spaces are called whitespaces.

We usually remove them to make the text look clean.

Python
This question was asked as part of the Learn Python Basics course.
Ritika Gangwar
2 months ago
Ritikacountry asked
Kelish Rai
Expert
last month
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
2 months ago
Kelish Rai answered

Since you already know how range() works, let’s look at an example to understand how the step argument works.

Consider this code:

print(list(range(1, 6)))

Output

[1, 2, 3, 4, 5]

Here, the list goes up by 1 each time by default.

Now let’s add 2 as the step:

print(list(range(1, 6, 2)))

Output

[1, 3, 5]

In this case, the list still starts at 1, but it jumps by 2 instead of 1.

So, the step argument simply controls how much the value increases by in each step.

Let me know if you need more clarification on this.

Python
This question was asked as part of the Learn Python Basics course.
Kelish Rai
Expert
2 months ago
Kelish Rai answered

When performing arithmetic operations in Python, the result will be a floating-point number if you use the / operator for division. For example, 5 / 2 will give you 2.5.

If you're using operations like addition (+), subtraction (-), or multiplication (*), the result will be in floating-point only if any of the values involved are floating-point numbers. For example, 5 + 2.2 will give you 7.2.

If you use the // operator for integer division, like 5 // 2, the result will be an integer (in this case, 2).

This distinction helps you get the result you expect, depending on the type of operation and the numbers involved.

Python
This question was asked as part of the Learn Python Basics course.
Sudip Bhandari
Expert
2 months ago

The reason the numbers 25 and 100 aren’t inside quotes is because they are being treated as numeric values, not text (strings).

In Python, when you put a number inside quotes, it becomes a string—which is a different data type.
If you want to perform calculations like addition, subtraction, or division, you should keep numbers without quotes so Python knows they are numeric values.

In your example:

age = 25
print(age)

age = 100
print(age)

Here, age is initially assigned the numeric value of 25 and later changed to 100. That's why you see them without quotes and why they print as numbers.

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

Python
This question was asked as part of the Learn Python Basics course.
Sarravanabavan Durairaj
PRO
2 months ago
Sarravanabavancountry asked
Sudip Bhandari
Expert
2 months ago

That's a great question!

In Python, int is actually a class, and any number you create (like 1) is an object of that class.

For example, when you write:

number = 1

Here, number is an object of the int class. You can check this using the type() function:

print(type(number))  # Output: 

This shows that int is a class, and every integer you create is an object (or instance) of that class.

Hope this helps!

Python
This question was asked as part of the Learn Python Intermediate course.
maruthaveeran thanujan
2 months ago
Maruthaveerancountry asked
Sudip Bhandari
Expert
2 months ago

Great question! In Python, def is a keyword used to define a function.

A function is a block of reusable code that performs a specific task—you define it once and can use it as many times as you like.

Example:

def greet(name):
    print(f"Hello, {name}!")

In the code:

  • def tells Python that you're defining a function.

  • greet is the name of the function.

  • (name) is a parameter the function takes.

  • The indented line below it is the function body, which runs when the function is called.

To actually use the function, you'd call it like this:

greet("Alice")  # Output: Hello, Alice!

Why use functions?

  • They help you avoid repeating code.

  • They make your programs easier to read and maintain.

  • You can break a complex task into smaller parts.

Python
This question was asked as part of the Learn Python Basics course.
B
2 months ago
Bhumikacountry asked
Sudip Bhandari
Expert
2 months ago

Here, greeting is a variable. When you print a variable, you get the value stored inside it as the output.
That’s why when you print greeting, you see Merry Christmas—because that's the value stored in the variable.

If you want to print the word greeting itself (not the value), you need to enclose it in quotes, like this:

print("greeting")

In this case, "greeting" is treated as a string, not a variable. So the output will simply be:

greeting

Quick reminder:

  • Without quotes → Python treats it as a variable and shows its value.

  • With quotes → Python treats it as plain text (a string).

Hope this clears things up! Let me know if you have any other questions.

Python
This question was asked as part of the Learn Python Basics course.
MONG QI SHENG Moe
2 months ago
Mongcountry asked
Sudip Bhandari
Expert
2 months ago

In Python, we use the if...else statement to make decisions. For example:

age = 19

if age >= 18:
    print("The person can enter inside the club.")
else:
    print("The person cannot enter inside the club.")

We have a dedicated lesson on if...else, so you’ll learn more about it as you continue the course.
For now, I recommend just keeping the flow and moving forward step-by-step.

If you want to jump ahead and learn about it right now, you can visit: if...else Statement | Programiz PRO

Hope this helps!

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