Questions #1



Download 85,32 Kb.
bet20/24
Sana06.07.2022
Hajmi85,32 Kb.
#752107
1   ...   16   17   18   19   20   21   22   23   24
Bog'liq
interview en

Design


  • URL shortener service

Questions #4

150 interview questions for a Python job. Part 1 (no work experience).


Translation from English material published on a major Python learning portal. Part 1 is devoted to an overview of the categories of questions that are most often asked to beginners, with no work experience, who want to fill a vacancy in Python. To prepare for an interview, you need to have the answer to the following and other similar questions about the main features of python, its advantages and disadvantages, the use of basic types, functions and operators ready.
Source: 150+ Python Intervi

Common Python Questions with Answers


IN 1. The main features of python?
If python happens to be the first language in the programming experience, you need to have a general understanding about it. What are its main features:
is an interpreted language
- it has dynamic data typing
is an object-oriented language
- it is concise and outwardly simple
- distributed free of charge
- has a large community
IN 2. What is the difference between lists and tuples?
The main difference is that a list is mutable while a tuple is immutable.
>>> mylist = [1, 3, 3]
>>> mylist[1] = 2
>>> mytuple = (1, 3, 3)
>>>mytuple[1] = 2
Traceback (most recent call last):
File “
”, line 1, in
mytuple[1] = 2
TypeError: "tuple" object does not support item assignment
AT 3. How does the ternary operator work in python?
Python has these expressions:
[if true] if [expression] else [if false]
That is, when the expression is true (True), then the code is executed [if true]. Otherwise, the code is executed [if false]. For example:
>>> a, b = 2, 3
>>> min = a if a < b else b
>>> min
2
>>> print("Hi") if a < b else print("Bye")
Hi
AT 4. What is a negative index?
Let's take a list as an example:
>>> mylist = [0, 1, 2, 3, 4, 5 ,6, 7, 8]
Unlike a positive index, a negative one starts the search from the end:
>>>mylist[-3]
6
It also helps when creating slices from the end:
>>>mylist[-6:-1]
[3, 4, 5, 6, 7]
AT 5. Python is case sensitive?
A language is considered case sensitive if it distinguishes between "myname" and "Myname". That is, if it keeps track of the case difference (between upper and lower). Let 's see how With this in python .
>>> myname="Ayushi"
>>>Myname
Traceback (most recent call last):
File “
”, line 1, in
myname
NameError: name "Myname" is not defined
We made sure that python is case sensitive.
AT 6. Maximum allowable length of an identifier in python?
In python, an identifier can be of any length. In addition, there are several rules for naming:
- the first character can be an underscore (_), the characters AZ or az;
- the rest of the name may consist of characters AZ/az/_/0-9;
- do not forget that python is case sensitive;
- keywords cannot be used as a name:
and, def, False, import, not, True, as, del, finally, in, or, try, assert, elif, for, is, pass, while, break, else, from, lambda, print, with, class, except, global, None, raise, yield, continue, exec, if, nonlocal, return.
AT 7. How can I convert a string (string) to lowercase (lowercase)?
The lower() method is used for this:
>>> "AyuShi".lower()
"ayushi"
To convert to uppercase (uppercase), use the upper() method:
>>> "AyuShi".upper()
"AYUSHI"
There are also isupper() (all uppercase characters) and islower() (all lowercase characters) methods that check the case of all characters in the name.
>>> "AyuShi".isupper()
False
>>> "AYUSHI".isupper()
True
>>> "ayushi".islower()
True
>>> "@yu$hi".islower()
True
>>> "@YU$HI".isupper()
True
As you can see, characters like @ and $ are applicable in both cases.
There is also the istitle() method, which checks the string for the title style (all words must start with an uppercase character):
>>> "The Corpse Bride".istitle()
True
8. For _ what need a pass (pass statement) in python ?
Sometimes it is necessary that the code does not give any result and does not show an error, for example, if it is not ready yet, but you need to have syntactically correct code. You can put pass:
>>> def func(*args):
pass
In addition to it, there is a break (break statement), which breaks the loop:
>>> for i in range(7):
if i == 3: break
print(i)
0
one
2
Finally, there is a continue (continue statement) that jumps to the next iteration:
>>>for i in range(7):
if i==3: continue
print(i)
0
one
2
four
5
6

Download 85,32 Kb.

Do'stlaringiz bilan baham:
1   ...   16   17   18   19   20   21   22   23   24




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish