Skip to content

Instantly share code, notes, and snippets.

@roman-on
Created May 17, 2020 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roman-on/8afec606fd6c38d6890f736f246b73ff to your computer and use it in GitHub Desktop.
Save roman-on/8afec606fd6c38d6890f736f246b73ff to your computer and use it in GitHub Desktop.
"""
Create a dictionary with a name of your choice and format it according to the following table:
first_name Mariah
last_name Carey
birth_date 27.03.1970 (string)
hobbies Sing, Compose, Act (tuple)
Write a program that does the following, three to the user's digit:
1. Print Maria's surname on the screen.
2. Print the screen the month Maria was born.
3. Print on screen the number of hobbies Maria has.
4. Print the latest hobby on Maria's hobby list.
5. Add the "cooking" hobby to the end of the hobby list.
6. Turn the birthdate type into a Tuple that contains 3 numbers (day, month and year - left to right) and print it.
7. Add a new key named age which includes Maria's age and show it.
Instructions:
Ask the user to input (number from 1 to 7) and assume the input is correct.
"""
"""
my_dict = {"first_name":"Mariah", "last_name":"Carey", "birth_date":"27.03.1970", "hobbies":["Sing", "Compose", "Act"]}
"""
input1 = input("press a number between 1 - 7")
1.
print (my_dict["last_name"])
2.
a = my_dict["birth_date"]
print (a[3:5])
3.
a = my_dict["hobbies"]
len(a)
4.
a = my_dict["hobbies"]
print(a[-1])
5.
a = my_dict["hobbies"]
b = "Cooking"
a.append(b)
my_dict["hobbies"] = a
print(my_dict["hobbies"])
6.
a = my_dict["birth_date"]
b = a[0:2],a[3:5], a[6::]
print(b)
7.
my_dict["age"] = "50"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment