Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 1
- print("***** 1 *****")
- people = [
- {
- "Name" : "Anto",
- "Age" : "15",
- "Hobby" : "Football"
- },
- {
- "Name" : "Budi",
- "Age" : "20",
- "Hobby" : "Coding"
- },
- {
- "Name" : "Charlie",
- "Age" : "12",
- "Hobby" : "Gaming"
- }
- ]
- for person in people :
- print(person["Name"])
- print(f"Age : {person['Age']}")
- print(f"Hobby : {person['Hobby']}")
- print()
- # 2
- print("***** 2 *****")
- pets = [
- {
- "typeOfPet" : "Dog",
- "ownersName" : "Angelice",
- "breed" : "Chihuahua",
- "color": "Black"
- },
- {
- "typeOfPet" : "Cat",
- "ownersName" : "Broody",
- "breed" : "Anggora",
- "color": "White"
- },
- {
- "typeOfPet" : "Dog",
- "ownersName" : "Charlie",
- "breed" : "Bulldog",
- "color": "Brown"
- },
- {
- "typeOfPet" : "Cat",
- "ownersName" : "Dudes",
- "breed" : "Persian",
- "color": "Gray"
- }
- ]
- for pet in pets :
- for key, val in pet.items() :
- print(f"{key.title()} \t: {val.title()}")
- print()
- # 3
- print("***** 3 *****")
- cities = {
- "Jakarta" : {
- "Population" : 10560000,
- "FunFact" : "Memiliki stasiun kereta api terbesar se-ASEAN"
- },
- "Palembang" : {
- "Population" : 1600000,
- "FunFact" : "Merupakan kota tertua di Indonesia"
- }
- }
- for city in cities :
- print(city)
- for key, val in cities[city].items() :
- print(f"{key} \t: {val}")
- print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement