Programming in Python [Topic 1-6]

Replenishment date: 18.01.2024
Contents: programmirovanie-na-yazyke-python-tema-1-6.pdf (114.21 KB)
️Automatic issue of goods ✔️
Sales:
0
Refunds:
0
Reviews:
0
Views:
18
Seller
Seller:
alevtina_sar
Rating:
3,21
Ask a Question
Report a violation
Description
Where should you explicitly declare a function in one script?
Answer type: Single choice • with the choice of one correct answer from several proposed options

After calling this function
Before calling this function
Only in another file
What is the difference between iterators and generators?
Answer type: Single choice • with the choice of one correct answer from several proposed options

A generator is a mechanism for traversing data element-by-element, and an iterator allows you to lazily create a result when iterating.
no difference;
An iterator is a mechanism for traversing data element-by-element, and a generator allows you to lazily create a result when iterating.
You have been given a task. Create a class called Dog. When creating an instance of the Dog class, it must be possible to assign a value to the name property. What is the correct code option so that after creating the instance, you can also get the value of the name property?
Answer type: Single choice • with the choice of one correct answer from several proposed options

class Dog: def __init__(self, name): self.name = name def get_name(self): return self.name my_dog = Dog("Mukhtar") print(my_dog.get_name())
className Dog: def __init__(this, name): this.name = name my_dog = new Dog() my_dog.set(name, “Mukhtar”) print(my_dog.get(name))
class Dog: def __init__(self, name): self.name = name def get_name(self): return self.name my_dog = new Dog(“Mukhtar”) print(my_dog.get_name())
You have created a list that contains the following numbers: 4, 8, 15, 16, 23, 42 and included it in the my_list variable. What is the fastest way to calculate the sum of the numbers in this list?
Answer type: Single choice • with the choice of one correct answer from several proposed options

Use a for loop
Use a while loop and the sum function
Use the sum function
Select the odd one out:
Answer type: Multiple choice • with the choice of several correct answers from the proposed options

Switch
CASE​
break
keep on going
while
What is the keyword “self” used for? For example, def __init__(self):?
Answer type: Single choice • with the choice of one correct answer from several proposed options

This is a common variable for all code, which is set at the very beginning
To refer to the current function, Python uses the self keyword
The keyword self is a variable that refers to an instance of an object
How can I convert my_string to a list?
Answer type: Single choice • with the choice of one correct answer from several proposed options

tuple(my_string)
list(my_string)
dict(my_string)
How can you sort a list?:
Answer type: Multiple choice • with the choice of several correct answers from the proposed options

Write your own sorting function or use the sort() method
Write bubble sort
Lists cannot be sorted
How to create a list in Python?
Answer type: Single choice • with the choice of one correct answer from several proposed options

two square brackets []
two curly braces {}
two parentheses ()
What command is used to connect modules?
Answer type: Single choice • with the choice of one correct answer from several proposed options

imports.
pip install.
update.
Which function is used to output information to the console?
Answer type: Single choice • with the choice of one correct answer from several proposed options

threw out()
input ()
print ()
What programming paradigms and styles does Python support?
Answer type: Multiple choice • with the choice of several correct answers from the proposed options

Object-oriented
Modular
Programming in Constraints
Functional programming
What characteristics can be attributed to the Python language?
Answer type: Multiple choice • with the choice of several correct answers from the proposed options

Interpretable
Dynamically typed
Using a processor for macro substitutions
For rapid program development
How to Avoid Error Handling in Python Using Try: Except:
Additional Information
Why will this code throw an error?: print(int(True) // float(False))
Answer type: Single choice • with the choice of one correct answer from several proposed options

You can't divide True by False because they are boolean values
You can't divide an int into a float
Cannot divide by 0
Suppose you enter a natural integer into the variable num, using the line of code: num = int(input("Enter an integer: ")) And then you want to concatenate this number with the string “Python” to get, for example, “1234Python” . What do you need for this?
Answer type: Multiple choice • with the choice of several correct answers from the proposed options

I will write a code that will output a line. This will be enough: print(num + "Python")
I'll add try: except: blocks and handle the TypeError exception
I will give a variable num with type 'str'
Difference between is and ==?
Answer type: Single choice • with the choice of one correct answer from several proposed options

is tests for identity (of objects), and == tests for equality (of values).
no difference;
== tests for identity (of objects) and is tests for equality (of values).
Using what function can you get the length of an object if it is a list/tuple/dictionary/string?
Answer type: Single choice • with the choice of one correct answer from several proposed options

object(len)
len(object)
object.len()
How can you derive Fibonacci numbers?
Answer type: Multiple choice • with the choice of several correct answers from the proposed options

Using a recursive function that you can write yourself
Using a for / while loop
Create a special generator and place it in the Fibo class
We have a tuple my_tuple = (1, 82, 21). How can we add the new value 38 to it? Let's agree that we are not creating a new tuple, but we want to add a new element to it
Answer type: Single choice • with the choice of one correct answer from several proposed options

my_tuple.append(38)
my_tuple[3] = 38
A tuple is an immutable set of data
We have a script my_functions. How to connect it to the new script my_script if the module and the new script are in the same directory?
Answer type: Multiple choice • with the choice of several correct answers from the proposed options

connect my_functions
import my_functions
import my_functions as mf
What will this code output? def send_message(message="User did not specify a message"): return message msg = 1 + "22" send_message(msg)
Answer type: Single choice • with the choice of one correct answer from several proposed options

The user has not specified messages
122
An exception will be thrown: TypeError: unsupported operand type(s) for +: ´int´ and ´str´
What will this code output? print("Hello, Python!", end=" ") print("I'm a Python developer course", end="\n :)")
Answer type: Single choice • with the choice of one correct answer from several proposed options

Hello Python! ¶ I'm taking a Python developer course ¶ :)
Hello Python! I'm taking a Python developer course ¶ :)
An error will occur
What will this code output? S = 0 for i in range(1, 10): if i % 2 == 0: S = S + i print(S)
Answer type: Single choice • with the choice of one correct answer from several proposed options

0
10
20
30
What will this code output? try: print(1) except Exception: print(0)
Answer type: Single choice • with the choice of one correct answer from several proposed options

1
0
Exception
What will this code output?: lst = [[1, 2, 3], [4, 5], [6], [7, 8, 9]] print(sum(lst, []))
Answer type: Single choice • with the choice of one correct answer from several proposed options

Error because lists cannot be merged
The output will be: [1, 2, 3, 4, 5, 6, 7, 8, 9]
The output will be: [1, 9, 2, 8, 3, 7, 4, 6, 5]
What does this code mean: super().__init__() ?
Answer type: Single choice • with the choice of one correct answer from several proposed options

This construction is used to create an instance of the base class when creating an e
Similar items
Programming in Python
Seller:
alevtina_sar
Rating:
3,21
Sales:
0
price:
1,63 $
Programming video in Python 3.6
Rating:
0,4
Sales:
1
price:
10,00 $
Bash Programming
Seller:
antony van rean
Rating:
0
Sales:
0
price:
1,00 $
Sending messages (send e-mail) Python (+ diploma)
Seller:
s_sergeevich
Rating:
0,06
Sales:
0
price:
11,00 $