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.

If you're asking about spaces within a single line of code, like this:
age = 19or
age = 19Then no, the extra spaces don’t matter—both lines work the same way.
However, spaces inside a string do matter:
"My age is:"is not the same as
"My age is:"In the first example, there's a single space between "My" and "age", while in the second example, multiple spaces exist between the words. Python will treat these as completely different strings.
Python Indentation
The most important aspect of spacing in Python is indentation. Python uses indentation (spaces or tabs) to define code blocks. Unlike some other programming languages that use {} or similar syntax to group code, Python relies on indentation to structure the code.
For example:
if age > 18:
print("You are an adult!")Notice the indentation (four spaces) before print(). This tells Python that print() is inside the if block. If the indentation is incorrect or missing, you'll get an IndentationError.
Incorrect indentation:
if age > 18:
print("You are an adult!") # This will cause an errorPython requires consistent indentation, usually four spaces per level, to properly understand the structure of your code.
Key Takeaways:
Spaces around operators in expressions generally don’t matter.
Spaces inside strings are important.
Indentation is crucial for defining code blocks in Python and will cause errors if incorrect.

That's right. Quadratic time complexity (O(n²)) is commonly associated with nested loops, where the number of operations grows in proportion to the square of the input size.
For example, consider this Python code:
# This function runs n * n times
def print_pairs(arr):
for i in range(len(arr)):
for j in range(len(arr)):
print(i, j)
lst = [1, 2, 3, 4, 5]
print_pairs()Here, for every element in the list, another loop runs through all elements again, leading to O(n²) complexity.

Simply put, variables are containers for data.
For example, let's say your favorite book is Harry Potter and the Sorcerer’s Stone, and you want to use its name multiple times in a program. Instead of typing it every time like this:
print("Harry Potter and the Sorcerer’s Stone")
print("Harry Potter and the Sorcerer’s Stone")
print("Harry Potter and the Sorcerer’s Stone")You can store it in a variable and use it whenever needed:
book = "Harry Potter and the Sorcerer’s Stone"
print(book)
print(book)
print(book)This makes the code cleaner, easier to work with, and more efficient. If you ever need to change the book name, you only need to update the variable instead of modifying multiple lines of code.
It's okay if you don't fully understand how this works yet. As you continue with the course, you'll get a clearer understanding of variables and how they help in programming.
Let me know if anything is unclear—I’m happy to help.

F-strings are particularly useful when you want to insert variables directly into a string in a clean, readable, and concise way. They allow you to easily embed expressions inside string literals, which can make your code more readable and maintainable.
For example:
name = "Alice"
age = 25
print(f"My name is {name} and I am {age} years old.")In this case, {name} and {age} are placeholders within the string, and when the code runs, these placeholders get replaced by the actual values of the name and age variables.
Output:
My name is Alice and I am 25 years old.The key benefits of using f-strings are:
Clarity: It’s easy to understand what the code is doing.
Efficiency: It's faster than using string concatenation or other string formatting methods.
Flexibility: You can also perform expressions within the curly braces, not just simple variable replacements.
Example with an expression:
x = 5
y = 10
print(f"The sum of {x} and {y} is {x + y}.")Output:
The sum of 5 and 10 is 15.So, whenever you need to include variables or expressions inside a string, f-strings are a great option to use in Python.

If you're familiar with PEMDAS, the expression 2 * 5 - 10 / 5 follows the same order of operations.
Here’s a quick breakdown of PEMDAS:
Parentheses first (none here).
Exponents next (none here).
Multiplication and Division, from left to right.
Addition and Subtraction, from left to right.
Now, let’s see how Python evaluates the expression step by step:
2 * 5 = 10, so the expression becomes10 - 10 / 5.10 / 5 = 2.0, so now we have10 - 2.0.10 - 2.0 = 8.0.
Since division in Python always produces a float, the final result is 8.0 instead of an integer.
However, if you want the result without decimals, you can use // for integer division.
result = 2 * 5 - 10 // 5
print(result) # Output: 8In this case, the result would be an integer (8), not a float (8.0).

It seems there’s a slight confusion about what you're trying to achieve.
Firstly, "greeting" = "Merry Christmas" is incorrect, as you don’t need to enclose variables within quotation marks. The correct syntax would be:
greeting = "Merry Christmas"This way, greeting is correctly defined as a variable. Whereas Python would treat "greeting" as a string instead.
Similarly, the line print("greeting") won’t print "Merry Christmas" because of the quotation marks.
To correctly print the value of the greeting variable, you should write:
print(greeting)This will output "Merry Christmas" as expected.
Note: Think of variables as "labels" for values. If you wrap the label in quotes, Python thinks it's just a word, not a label pointing to something else.

When there are operators of the same precedence in an arithmetic operation, Python follows a specific rule called associativity to determine the order of evaluation.
Associativity defines the direction in which operations of the same precedence are processed:
Most arithmetic operators in Python (like
+,-,*,/) are left-associative, meaning they are evaluated from left to right.Some operators, like exponentiation (
**), are right-associative, meaning they are evaluated from right to left.
Example 1: Left-to-right associativity (for - and /)
result = 20 - 5 - 2 # evaluated as (20 - 5) - 2 = 13
print(result) # Output: 13Example 2: Right-to-left associativity (for **)
result = 2 ** 3 ** 2 # evaluated as 2 ** (3 ** 2) = 2 ** 9 = 512
print(result) # Output: 512If you're ever unsure, you can use parentheses to make the order of operations explicit. For example:
# Force a different order
result = (20 - (5 - 2)) # result is 17If you want to learn more about this, I recommend checking out the blog Understanding Operator Precedence and Associativity in Python. It explains this concept in a clear and structured way.

DSA (Data Structures and Algorithms) is all about solving problems efficiently using the right tools.
Data structures help organize and store data—like arrays, lists, stacks, queues, trees, and graphs.
Algorithms are step-by-step instructions to perform tasks like searching, sorting, or finding the shortest path.
Real-Life Examples of DSA in Action:
Search engines use efficient algorithms to return results in milliseconds.
Social media platforms use graph algorithms to suggest friends and show relevant content.
GPS apps use shortest path algorithms (like Dijkstra’s) to find the fastest routes.
E-commerce websites use sorting and recommendation algorithms to show you useful product suggestions.
In short, DSA makes software faster, smarter, and more responsive. It’s not just for interviews or school—it’s what helps technology scale and perform in the real world.
Learning DSA also builds strong problem-solving skills and helps you understand how systems work under the hood.
You can also check out our blog Data Structures and Algorithms in Everyday Life to learn more on this.

No, you don't need always quotation marks when creating variables. For example,
age = 25In this case, age is a variable that stores the value 25. Since 25 is a number, we don't need to use quotation marks around it.
However, if you're storing a string in a variable, you must enclose the value with quotation marks. For example,
favorite_food = "Pizza"Here, favorite_food is a variable, storing the string "Pizza".
As for spaces around the equal sign, Python doesn’t require them, but adding spaces makes the code easier to read:
age=25
age = 25Here, age=25 works but age = 25 is cleaner and easier to understand.

Yes, you can use f-strings outside of print().
An f-string is just a formatted string, meaning you can use it anywhere a string is used.
Example 1: Assigning to a variable:
name = "Alice"
message = f"Hello, {name}"
print(message) # Output: Hello, AliceExample 2: Writing to a file:
age = 30
with open("info.txt", "w") as file:
file.write(f"User age: {age}")Example 3: Passing as a function argument:
def greet(msg):
print(msg)
greet(f"Welcome back, {name}!")In all of these examples, the f-string is being used to build a string dynamically with variables or expressions, then used just like any regular string—stored, written, passed, or returned.
F-strings are one of the most efficient and readable ways to format strings in Python, and you'll keep finding more ways to use them as your projects grow.
Our Experts
Sudip BhandariHead of Growth/Marketing
Apekchhya ShresthaSenior Product Manager
Kelish RaiTechnical Content Writer
Abhilekh GautamSystem Engineer
Palistha SinghTechnical Content Writer
Sarthak BaralSenior Content Editor
Saujanya Poudel
Abhay Jajodia
Nisha SharmaTechnical Content Writer
Udayan ShakyaTechnical Content Writer