User Tools

Site Tools


fcp:faq

Frequently Asked Questions

* Why do we learn Python?

  • Well, we have to pick something and Python (with its easy syntax and plenty of functionalities and supporting libraries) seems to be a good choice for beginners.

* Isn't Python slow?

  • Not so bad for current situation (hardware, interpreter, and JIT).

* Is Python interpreter?

  • Yes, but it is not the ancient interpreter. Modern python has many new technologies to mitigate he cons of interpreter-based eco.

* Why do we do the following code?

if __name__ == '__main__':
  • It looks nicer, and our program will well behave in many situations.

* Does Python have a pointer, like C?

  • Not as explicit as C.

* Do Python pass by reference or by value?

  • Depends on the data type passed.

* Can Python do OOP?

  • Definitely. Check out keyword ```class```.

* What is OOP? and what is it for?

  • OOP is a one nice programming paradigm, and it is pretty much for better organized code.

* What is 'function' for?

  • It is to organize a set of instructions into a coherent concept for easy access multiple times later.

* Why do I have to pass variables through function arguments, when I can use global variables?

  • It is more convenient in many situations. Using global variables may obscure code visibility and is likely to cause errors or bugs. Though using global variables is not a sin, but them consciously and prudently.

* Why do we need 'for loop', when we can do 'while loop'?

  • We use ```for``` when we have an idea how many times we want it to repeat.
  • We use ```while``` when a number of times it repeats depends on a condition.

* Why do we need a 'List'?

  • Many times, we need to work on a collection of values, rather than just single value at a time.

* What is the difference between list and dict?

  • Both are collections, but list is accessed by the order of its item, while dict is accessed through `key`.

* Why does Python pass a list reference when we assign 'y = x' where x is a list?

  • Internally, list is a big object (in term of OOP), it is more economical to pass a reference, rather than copying over a large chunk of data.

* Why do we have to 'import'?

  • It is a natural way to “pack” only what we need, rather having nothing at all or having everything with us all the time.

* Why are '5' + '3' different from 5+3?

  • Python interprets '5' as a string, while 5 as a number. Otherwise, how does it know which from which?

* What is a 'method'? and how is it different from a 'function'?

  • `method` is a concept in OOP. It is more like a function specific to an object (“data type”).

* What does this 'i += 1' mean?

  • Try it out! And, you will learn 'i += 1' functions as 'i = i + 1'.

Hey! it is good to ask questions, but having hands-on the code, experimenting, trying them out are the best way to learn.

fcp/faq.txt · Last modified: 2025/09/30 12:00 by tatpong_katanyukul

Page Tools