-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreturn_function_2.py
More file actions
80 lines (73 loc) · 2.56 KB
/
return_function_2.py
File metadata and controls
80 lines (73 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
def get_formatted_name(first_name, last_name, middle_name = ''):
"""Возвращает аккуратно отформатированное полное имя."""
if middle_name:
full_name = first_name + ' ' + middle_name + ' ' + last_name
else:
full_name = first_name + ' ' + last_name
return full_name.title()
musician = get_formatted_name('jimi', 'hendrix')
print(musician)
musician = get_formatted_name('john', 'hooker', 'lee')
print(musician)
def build_person(first_name, last_name):
person = {'first' : 'first_name', 'last' : 'last_name'}
return person
musician = build_person('jack', 'jackiel')
print(musician)
def build_person(first_name, last_name, age = ''):
person = {'first' : 'first_name', 'last' : 'last_name'}
if age:
person['age'] = age
return person
musician = build_person('jack', 'jackiel', age=21)
print(musician)
def get_formatted_name(first_name, last_name):
full_name = first_name + ' ' + last_name
return full_name.title()
while True:
print("\nPlease tell me your first name: ")
print("\nOr insert quit for exit")
f_name = input("First name: ")
if f_name == 'quit':
break
print("\nPlease tell me your last name: ")
print("\nOr insert quit for exit")
l_name = input("Last name: ")
if l_name == 'quit':
break
formatted_name = get_formatted_name(f_name, l_name)
print("\nHello " + formatted_name)
#def get_formatted_name(first_name, last_name):
# return full_name.title()
#while True:
# print("\nPlease tell me your name: ")
# formatted_name = get_formatted_name(f_name, l_name)
#print("\nHello " + formatted_name + "!")
def city_country(city, country):
c_country = city + ', ' + country
return c_country.title()
city_count = city_country('Moskow', 'Russia')
print(city_count)
city_count = city_country('Pekin', 'China')
print(city_count)
city_count = city_country('Kazahstan', 'Astana')
print(city_count)
def make_album(author_album, album_songs, track = ''):
author_album = {'author' : author_album, 'album' : album_songs}
if author_album:
author_album['track'] = track
return author_album
while True:
print("\nInsert name album or author")
print("Insert q for quit")
answer = input("\nInsert your choise:")
first = make_album('Viktor Tscoi', 'Kino',track=3)
print(first)
second = make_album('Malchishnik', 'Klava', track=7)
print(second)
third = make_album('Mr.robot', 'Main theme', track=5)
print(third)
if answer == 'q':
break
if answer == 'a':
print(first)