This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print ('Приветствуем вас в калькуляторе Python') | |
q1 = int (input('Введите число 1: ')) | |
q2 = int (input('Введите число 2: ')) | |
v = int (input('Какую операцию вы хотите выполнить? \n 1 Сложение \n 2 Вычитание \n 3 Деление \n 4 Умножение \n')) | |
if v == 1: | |
r = q1 + q2 | |
p = 'сложения' | |
t = p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = (43, 56, 45.23, 'd') #Это называется кортеж-неизменяеимый массив | |
b = [43, 56, 45.23, 'd'] #бычный список-массив | |
b[0] = 34 | |
print (a.__sizeof__()) | |
print (b.__sizeof__()) | |
a = tuple('Hello world!') #_tuple разделяет строку на отдельные символы | |
print (a) | |
a = ('hello world', 'sdf', 123) #скобки необязательны, но очень желательны | |
print (a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
l = [34, 'sd', 56, 34.34] | |
i = 0 | |
while i < 4: | |
print (l[i]) | |
i += 1 | |
print (l[2:]) #Возвращает элементы массива, начиная со второго | |
print (l[:2]) #озвращает элементы массива, заканчивая вторым | |
print (l[::2]) #озвращает каждый второй элемент массива, начиная с нулевого |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
l = [] #Список, в квадратных скобках | |
lis = [1, 56, 'x', 34, 2.34, ['S', 't', 'r', 'o', 'k', 'a']] | |
print (lis) | |
a = [a + b for a in 'List' if a!= 's' for b in 'soup' if b != 'u'] | |
print (a) | |
l.append (23) #Добавляет элемент в конец массива | |
l.append (34) | |
b = [24,67] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
q1 = int(input('Введите число 1: ')) | |
q2 = int(input('Введите число 2: ')) | |
if q1 % 2 == 0: | |
print('Число 1 четное') | |
else: | |
print ('Число 2 четное') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
num = int (input('ведите число: ')) | |
if num > 0: | |
if int (num) >10: | |
print ('Вы ввели число больше 10') | |
if int(num) > 50: | |
print('Вы ввели число больше 50') | |
else: | |
print ('Вы ввели чсло меньше 10 и больше 0') | |
elif int (num) < -10: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print ('Приветствую вас в калькуляторе питон') | |
num1 = input ('Введите первое число: ') | |
num2 = input ('Введите второе число: ') | |
print ('Результат сложения: ',int (num1) + int(num2)) | |
print ('Результат вычитания: ',int (num1) - int(num2)) | |
print ('Результат умножения: ',int (num1) * int(num2)) | |
print ('Результат целочисленного деления: ',int (num2) % int(num1)) | |
print ('Благодарим за работу в нашей программе!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print ('Приветствую вас в калькуляторе питон') | |
num1 = input ('Введите первое число: ') | |
num2 = input ('Введите второе число: ') | |
print ('Результат сложения: ',int (num1) + int(num2)) | |
print ('Результат вычитания: ',int (num1) - int(num2)) | |
print ('Результат умножения: ',int (num1) * int(num2)) | |
print ('Результат целочисленного деления: ',int (num2) % int(num1)) | |
print ('Благодарим за работу в нашей программе!') |