Yaml Pactics

For newbies can practicing and improve skill.

Instruction:

  1. Fork this repository to you account.
  2. Follow the insruction in each assignment.

Examples

In examples folder, there are some example of yaml file to learn before take an assignment.

Assignment 1

Which of the following is used to separate the key and value in YAML

choices

  • colon
  • semicolon
  • comma
  • hyphen

answer:

Assignment 2

How many array keys are there in the following yaml snippet?

Fruits:
  - Orange
  - Apple
  - Banana
Vegetables:
  - Carrot
  - CauliFlower
  - Tomato

answer:

Assignment 3

Which of the following statements is true?

A. Dictionary is an unordered collection whereas list is an ordered collection.

B. Dictionary is an ordered collection whereas list is an unordered collection.

C. Dictionary and list, both are an ordered collection.

D. Dictionary and list, both are an unordered collection.

Answer:

Assignment 4

There is a yaml file named practice.yaml which directory with a key property1 and value value1.

Add an additional key named property2 and value value2.

Assignment 5

We have updated the practice.yaml file with the key name and value apple. Add some additional properties (given below) to the dictionary.

name= apple color= red weight= 90g

Assignment 6

We have updated the practice.yaml file with a dictionary named employee. Add the remaining properties to it using information from the table below.

Key/Property Value name john gender male age 24

Now, update the /home/bob/playbooks/practice.yaml file with a dictionary in dictionary.

Add a dictionary named address to add the address information in this file.

Key/Property Value city edison state new jersey country united states

Assignment 8

  1. In this folder, there is a file practice.yaml with an array of apples. Add a new apple to the list to make it a total of 6.

Assignment 9

We have updated the practice.yaml file with some data for apple, orange and mango. Just like apple, we would like to add additional details for each item, such as color, weight etc. Modify the remaining items to match the below data.

orange

colorweight
orange90g

mango

colorweight
yellow150g

Assignment 10

We have updated the practice.yaml file with a dictionary named employee. We would like to record information about multiple employees. Convert the dictionary named employee to an array named employees.

Assignment 11

Update the /home/bob/playbooks/practice.yaml file to add an additional employee (below the existing entry) to the list using the below information.

Key/PropertyValue
namesarah
genderfemale
age28

Assignment 12

We have updated the /home/bob/playbooks/practice.yaml file to add some more details. Now add the pay information. Remember, while address is a dictionary, payslips is an array of month and amount.

payslips

monthamount
june1400
july2400
august3400

Yaml Knowledge is here

FileName

Yaml file extension name are .yaml or .yml but for each project, you should follow the name convention.

Dictionary

The basic of configuration languages is dictionary type. So, it's simple is that just key and value.

name: John
age: 30
gender: male

Map Objects

Similar to dictionary but in a key, there are some attribute inside a key.

person:
  name: John
  age: 30
  gender: male

Collection / List

charactors:
  - Anakin
  - Obi-Wan
  - Padme