Базовые типы данных. Ввод и вывод. Арифметические операции. (Python): различия между версиями

Материал из Информационная безопасностя
Перейти к навигации Перейти к поиску
(Новая страница: «== Базовые типы данных == <syntaxhighlight lang="python" line> foo = 6 bar = 4.5 baz = "Hello" letter = 'c' no = False cars = ["Ford", "Volvo", "...»)
 
 
(не показано 7 промежуточных версий этого же участника)
Строка 1: Строка 1:
 +
{{TOCRight}}
 
== Базовые типы данных ==
 
== Базовые типы данных ==
 +
* [https://docs.python.org/3/library/stdtypes.html Built-in Types]
 
<syntaxhighlight lang="python" line>
 
<syntaxhighlight lang="python" line>
 
foo = 6
 
foo = 6
Строка 10: Строка 12:
  
 
== Ввод и вывод ==
 
== Ввод и вывод ==
 +
* [https://docs.python.org/3/tutorial/inputoutput.html Ввод и вывод (документация)]
 
<syntaxhighlight lang="python" line>
 
<syntaxhighlight lang="python" line>
 
print('Введите ваш возраст:')
 
print('Введите ваш возраст:')
 
age = int(input())
 
age = int(input())
 +
temp = float(input())
 
print('Ваш возраст = ' + str(age))
 
print('Ваш возраст = ' + str(age))
 +
</syntaxhighlight>
 +
 +
<syntaxhighlight lang="python" line>
 +
a, b = map(int, input().split())
 +
</syntaxhighlight>
 +
 +
<syntaxhighlight lang="python" line>
 +
a = 1.123456
 +
print(f"{a:.3f}")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
== Арифметические операции ==
 
== Арифметические операции ==
 +
* [https://docs.python.org/3/tutorial/introduction.html#using-python-as-a-calculator Расчёты (документация)]
 
<syntaxhighlight lang="python" line>
 
<syntaxhighlight lang="python" line>
 
fahrenheit = celcius*1.8 + 32
 
fahrenheit = celcius*1.8 + 32
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
== Задачник ==
 +
* [http://ptaskbook.com/ru/tasks/begin.php Ввод и вывод данных, оператор присваивания]

Текущая версия на 14:11, 6 октября 2022

Базовые типы данных

1 foo = 6
2 bar = 4.5
3 baz = "Hello"
4 letter = 'c'
5 no = False
6 cars = ["Ford", "Volvo", "BMW"]

Ввод и вывод

1 print('Введите ваш возраст:')
2 age = int(input())
3 temp = float(input())
4 print('Ваш возраст = ' + str(age))
1 a, b = map(int, input().split())
1 a = 1.123456
2 print(f"{a:.3f}")

Арифметические операции

1 fahrenheit = celcius*1.8 + 32

Задачник