Questions #1


Top Python Questions with Answers



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

Top Python Questions with Answers


B57. How to work with numbers that are not included in the decimal number system?
In python, you can enter binary, octal and hexadecimal numbers.
Binary. These are numbers made up of 0 and 1. For binary input, the prefix 0b or 0B is used:
>>> int(0b1010)
ten
A number can be converted to binary using the bin() function:
>>>bin(0xf)
'0b1111'
Octal numbers can consist of digits from 0 to 7, and the prefix 0o or 0O is also used:
>>> oct(8)
'0o10'
Hexadecimal numbers can consist of digits from 0 to 15, the prefix 0x or 0X is also used:
>>> hex(15)
'0xf'
B58. What is the result of this code:
>>> def extendList(val, list=[]):
list append(val)
return list
>>> list1 = extendList(10)
>>> list2 = extendList(123,[])
>>> list3 = extendList('a')
>>> list1, list2, list3
[10, 'a'], [123], [10, 'a']
Possible but incorrect answer: ([10], [123], ['a'])
The function has a list=[] argument that does not start at null every time this function is called. The first time we define a function, it creates a new list. Then, every time we call this function without a list argument, it uses the same list. Python evaluates expressions that have null values when defining a function, not when calling the function.
B59. How many arguments can range() take?
One to three:
>>> list(range(5))
[0, 1, 2, 3, 4]
>>> list(range(-5))
[]
>>> list(range(2, 7))
[2, 3, 4, 5, 6]
>>> list(range(-3, 4))
[-3, -2, -1, 0, 1, 2, 3]
>>> list(range(2, 9, 2))
[2, 4, 6, 8]
>>> list(range(9, 2, -1))
[9, 8, 7, 6, 5, 4, 3]
At 60. What such PEP 8?
This is a python programming convention that contains guidelines for improving code readability.
B61. How is Python different from Java?
If we compare Python and Java:
- Java is faster
- Python uses indentation, Java needs parentheses
- Python has dynamic typing, Java has static typing
- Python is simple and concise, and Java is a verbose language
- Python is an interpreted language
- Java is platform independent
- Java has a JDBC interface that improves database access
B62. What is the best way to swap the numeric values of objects?
>>> a, b = b, a
How this code is executed:
>>> a, b = 2, 3
>>> a, b = b, a
>>> a, b
(3, 2)
B63. How can you perform multiple assignment operations in a single clause?
First way (multiple objects with unique values):
>>> a, b, c = 3, 4, 5
Second way (multiple objects with identical values):
>>> a = b = c = 3
B64. How to get out of an endless loop?
You can press the key combination Ctrl + C, which interrupts the execution.

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