mirror of
https://github.com/denis-on/basicsPython.git
synced 2026-02-03 16:10:51 +03:00
task-01 ok
This commit is contained in:
parent
b61db0a89d
commit
20327a031a
@ -1,16 +0,0 @@
|
|||||||
# This is a sample Python script.
|
|
||||||
|
|
||||||
# Press Shift+F10 to execute it or replace it with your code.
|
|
||||||
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
|
|
||||||
|
|
||||||
|
|
||||||
def print_hi(name):
|
|
||||||
# Use a breakpoint in the code line below to debug your script.
|
|
||||||
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
|
|
||||||
|
|
||||||
|
|
||||||
# Press the green button in the gutter to run the script.
|
|
||||||
if __name__ == '__main__':
|
|
||||||
print_hi('PyCharm')
|
|
||||||
|
|
||||||
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
|
|
||||||
38
less-01/task-01.py
Normal file
38
less-01/task-01.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# 1. Поработайте с переменными, создайте несколько, выведите на экран.
|
||||||
|
# Запросите у пользователя некоторые числа и строки
|
||||||
|
# и сохраните в переменные, затем выведите на экран.
|
||||||
|
|
||||||
|
one = 'раз'
|
||||||
|
two = 'два'
|
||||||
|
thre = 3
|
||||||
|
four = 4
|
||||||
|
five = 5.0
|
||||||
|
|
||||||
|
print(f'{one} {two} {thre} {four} {five} или так')
|
||||||
|
print('%s %s %03d %f %.2f' % (one,two,thre,four,five) )
|
||||||
|
|
||||||
|
ans = input("Привет! пообщаемся?(*/N) ") # проверяем только отрицательный ответ
|
||||||
|
|
||||||
|
while True:
|
||||||
|
if ans.lower() == "n":
|
||||||
|
print('Жаль :( ну пока')
|
||||||
|
break
|
||||||
|
print('Ура я "копм"')
|
||||||
|
name = input("А как тебя зовут? ")
|
||||||
|
|
||||||
|
while True: # можно и проверочку сделать как вариант
|
||||||
|
try:
|
||||||
|
num = int(input("Напиши целое число от 1 до 10: ")) # на целое не проверяем.
|
||||||
|
except ValueError:
|
||||||
|
print("Это не число, попробуйте снова.")
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
|
print('')
|
||||||
|
even = 'не четное' if num % 2 else 'четное'
|
||||||
|
print('Молодец {} ты ввел(а) число {} и оно {}'.format(name.title(),num,even))
|
||||||
|
|
||||||
|
ans = input("Ещё разок?(*/N) ")
|
||||||
|
print('-'*15)
|
||||||
|
print('\n'*2)
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user