You are on page 1of 14

Discussion 1.

1 | Introduction to Devnet
Compare python lists, tuples, and dictionaries.
Click Reply to share your answer.

A Python list contains a combination of types, strings, integers, and objects used to search,
insert, to count, remove or simply to append and extend that can be created using square
brackets or Python built-in, list.

Tuples
Tuples are similar to a list, but you can't change their values unlike lists and creating tuples
using parentheses are faster than lists. We can do tuple slicing, casting but cannot sort a tuple.

A Python dictionary can add, remove, and modify the values, they are indexed with keys that
can't change their values. Keys and values are not in any specific order or numbered.
Lists

A Python list is similar to an array in other languages. In Python, an empty list can be created in the
following ways.

>>> my_list = []

>>> my_list = list()

As you can see, you can create the list using square brackets or by using the Python built-in, list. A list
contains a list of elements, such as strings, integers, objects or a mixture of types. Let’s take a look at
some examples:

>>> my_list = [1, 2, 3]

>>> my_list2 = ["a", "b", "c"]

>>> my_list3 = ["a", 1, "Python", 5]

The first list has 3 integers, the second has 3 strings and the third has a mixture. You can also create lists
of lists like this:

>>> my_nested_list = [my_list, my_list2]

>>> my_nested_list

[[1, 2, 3], ['a', 'b', 'c']]

Occasionally, you’ll want to combine two lists together. The first way is to use the extend method:

>>> combo_list = []
>>> one_list = [4, 5]

>>> combo_list.extend(one_list)

>>> combo_list

[4, 5]

A slightly easier way is to just add two lists together.

>>> my_list = [1, 2, 3]

>>> my_list2 = ["a", "b", "c"]

>>> combo_list = my_list + my_list2

>>> combo_list

[1, 2, 3, 'a', 'b', 'c']

Yes, it really is that easy. You can also sort a list. Let’s spend a moment to see how to do that:

>>> alpha_list = [34, 23, 67, 100, 88, 2]

>>> alpha_list.sort()

>>> alpha_list

[2, 23, 34, 67, 88, 100]

Now there is a got-cha above. Can you see it? Let’s do one more example to make it obvious:

>>> alpha_list = [34, 23, 67, 100, 88, 2]

>>> sorted_list = alpha_list.sort()

>>> sorted_list

>>> print(sorted_list)

None

In this example, we try to assign the sorted list to a variable. However, when you call the sort() method
on a list, it sorts the list in-place. So if you try to assign the result to another variable, then you’ll find out
that you’ll get a None object, which is like a Null in other languages. Thus when you want to sort
something, just remember that you sort them in-place and you cannot assign it to a different variable.

You can slice a list just like you do with a string:


>>> alpha_list[0:3]

[2, 23, 34]

This code returns a list of just the first 3 elements.

>>> hostnames=["R1","R2","R3","S1","S2"]
>>> type(hostnames)
<class 'list'>
>>> len(hostnames)
5
>>> hostnames

Skip to content

 Home
 About Us
o
o
o
InfraExam 2021
 Cisco Netacad
o

o

o






o

o




o

o




 Linux
o
DevNet Associate (Version 1.0) – DevNet Associate Module 1
Exam Answers
1. >
2. DevNet – DEVASC>
3. DevNet Associate (Version 1.0) – DevNet Associate Module 1 Exam Answers
Last Updated on June 14, 2021 by Admin
DevNet Associate (Version 1.0) – DevNet Associate Module 1 Exam
Answers

  Recommend
   DevNet - DEVASC 1.0   
Final Exam Answers
This Modules 1
Modules 1 Exam Answers Online Test
Next Modules 2
Modules 2 Exam Answers Online Test
DEVASC v1 Student Lab Source Files Answers
1.1.2 Lab – Install the Virtual Machine Lab Environment Answers
1.2.2 Lab – Linux Review Answers
1.3.3 Lab – Python Programming Review Answers

1. A Linux system administrator is searching the passwd file for any username that starts
with a digit. Which grep command should the administrator use?
o grep ‘_[0-9]’ /etc/passwd
o grep ‘[0-9]’ /etc/passwd
o grep ‘^[0-9]’ /etc/passwd
o grep ‘{0-9}’ /etc/passwd
2. A student new to Python is working in the interactive interpreter mode. The student
issues the command:

Which Python expression can be used to retrieve the IP address of R2?


o ipAddress[‘R2’]
o ipAddress{“R2”}
o ipAddress{‘R2’}
o ipAddress[R2]
3. A system administrator attempts to determine what is causing a computer to perform
slower than normal. The administrator issues the ps command. What is displayed by
this command?
o current RAM usage
o current HDD usage
o active processes using CPU time
o current NIC status
4. What is the output when the following code is entered into a Python program
interpreter?

[1,2,4,5] + [3,6]
o [1,2,3,4,5,6]
o [1,2,4,5,3,6]
o [21]
o [12]+[9]
5. A student new to Python is working in the interactive interpreter mode. The student
issues the commands:

Which data type is used to represent the variable ipAddress?


o list
o array
o tuple
o dictionary
6. What is displayed after the following code is entered into a Python interpreter?

7. addition = 22 +10
print(addition)
o nothing ( because the print command is wrong)
o 32
o [22]+[10]
o (syntaxerror)-…as there should not be a space between the numerical values
8. Which Python command creates a conditional control structure?

o def
o if
o from
o delay
9. A Linux administrator is attempting to use a terminal to configure the network
interface card on a computer. The administrator receives a message that the
administrator does not have necessary permissions to perform the configuration. What
should be done prior to the configuration command?

o change the chmod permissions on the network configuration file


o use a different user account
o identify a different network interface
o use the sudo command
10. A user issues the Linux command ls -l myfile.sh to check the permission of
the file myfile.sh.
devasc@labvm:~/Documents$ ls -l myfile.sh
-rwxr-xr– 1 self test 15 Mar 30 21:24 myfile.sh
Which two statements describe the permissions assigned to the file? (Choose two.)

o Any user in the test group can execute the file.


o The user with the user ID of self can modify the file.
o The user with the user ID of devasc can modify the file.
o Any user in the self group can read, modify, and execute the file.
o All users can execute the file.
Answers Explanation & Hints:

The ls -l command provides a “long list” format with more information that includes the following:
File type: The hyphen (-) represents a regular file, the d represents a directory.
File permissions: The first three letters represent the permissions of the file owner over the file, the next
letters represent the permissions of the group over the file, and the last three letters represent the permis
others over the fie. The permission letters are as follows:

r- read or copy the file


w- write to the file
x- execute the file
hyphen (-) – no value assigned
Number of hard links to the file: 1 in this case
File owner, self in this case
File group: test in this case
File size. 15 bytes in this case
11. A user issues a series of Linux commands as shown.

12. (omitted)$ pwd
13. /home/devasc/labs/ansible/backups
(omitted)$ cd ../..
Which directory is the current directory after the cd command is entered?
o /
o /home
o /home/devasc/
o /home/devasc/labs
o /home/devasc/labs/ansible
14. A user enters the commands as shown. What is the result after the mv command is
entered?
15. devasc@labvm:~/Documents$ pwd
16. /home/devasc/Documents
devasc@labvm:~/Documents$ mv myfile.sh ../Desktop/myfile2.sh
o The file myfile.sh is moved to the /home/devasc/Desktop directory and renamed as
myfile2.sh.
o The file myfile.sh is copied to the /home/devasc/Desktop directory and replaces the
file myfile2.sh.
o The file myfile.sh is copied to the /home/devasc/Desktop directory and renamed as
myfile2.sh.
o The file myfile.sh is copied and renamed to myfile2.sh in the current directory.
17. A student is learning Python in the interactive interpreter mode. The student issues the
commands:

What is the result?

o ‘Test2’
o ‘TestTestTestTestTestTest’
o ‘TestTest’
o ‘Test6’
o TypeError: A string type cannot be multiplied by an integer.
18. A user issues a Linux command and the result is shown:

19. total 40
20. drwxr-xr-x 2 devasc devasc 4096 Mar 30 21:25 Desktop
21. drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09
Documents
22. drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09
Downloads
23. drwxr-xr-x 5 devasc devasc 4096 Mar 30 21:21 labs
24. drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09 Music
25. drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09
Pictures
26. drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09 Public
27. drwxr-xr-x 5 devasc devasc 4096 Mar 30 21:24 snap
28. drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09
Templates
29. drwxr-xr-x 2 devasc devasc 4096 Apr 15 19:09 Videos
devasc@labvm:~$
Which Linux command is used to display the contents of the current directory as
shown?

o ls -a
o ls
o ls -l
o ls -lr
Answers Explanation & Hints:

The Linux ls command with the -l option is used to display contents in the current directory with a lon
which provides more information about each file or subdirectory, such as permissions, owner, size, and
date.
30. A network engineer needs to review the status of all network interfaces of a server
running a Linux operating system. The engineer enters the command ifconfig
-a . What is the result of this command?
o All active interfaces will display information.
o The host routing table will be displayed.
o The ARP table of the computer will be displayed.
o Both active and inactive interfaces will display information.
31. A system administrator issues the apt-get upgrade command on a Linux
operating system. What is the purpose of this command?
o The remote repository of applications and dependencies will be updated to the latest
version.
o A specific application named upgrade will be installed.
o Operating system updates are downloaded and will be installed.
o Every application installed will update itself to the latest version.
Answers Explanation & Hints:

When the apt-get upgrade command is issued in a Linux terminal, all installed applications will at
upgrade to the latest version available.
32. A student new to Python is working in the interactive interpreter mode. The student
issues the commands:

What is the result?

o [‘RT1’, ‘RT2’, ‘SW1’, ‘RT3’, ‘SW3’]


o [‘RT1’, ‘RT2’, ‘RT3’, ‘SW2’, ‘SW3’]
o [‘RT1’, ‘RT2’, ‘SW1’, ‘SW2’, ‘SW3’]
o [‘RT1’, ‘RT2’, ‘SW2’, ‘RT3’, ‘SW3’]
33. A student is learning Python and is reviewing a Python script as follows:

Under which condition will the elif statement be evaluated?


o when the input is a float number
o when the first print statement fails
o when the if statement is false
o when the input is a string
  Recommend
   DevNet - DEVASC 1.0   
Final Exam Answers
This Modules 1
Modules 1 Exam Answers Online Test
Next Modules 2
Modules 2 Exam Answers Online Test
DEVASC v1 Student Lab Source Files Answers
1.1.2 Lab – Install the Virtual Machine Lab Environment Answers
1.2.2 Lab – Linux Review Answers
1.3.3 Lab – Python Programming Review Answers
4.5

Article Rating

 Subscribe 

{}[+]

0 COMMENTS
Search this website

 CCNA1 v7
 CCNA2 v7
 CCNA3 v7

System Test Exam Answers


Modules 1 – 3 Exam Answers
Modules 4 – 7 Exam Answers
Modules 8 – 10 Exam Answers
Modules 11 – 13 Exam Answers
Modules 14 – 15 Exam Answers
Modules 16 – 17 Exam Answers
Practice Final – ITN Answers
Course Feedback
ITN Practice PT Skills Assessment
(PTSA)
Final Exam Answers
Categories

 CCNA1 v7 – ITN – Lab Answers


 CCNA1 v7 – ITN – Packet Tracer Answers
 CCNA2 v7 – SRWE – Lab Answers
 CCNA2 v7 – SRWE – Packet Tracer Answers
 CCNA3 v7 – ENSA – Lab Answers
 CCNA3 v7 – ENSA – Packet Tracer Answers
 CyberOps Associate– CA – Lab Answers
 CyberOps Associate– CA – Packet Tracer Answers
 DevNet – DEVASC – Lab Answers
 DevNet – DEVASC – Packet Tracer Lab Answers
 ITEv7 – Lab Answers
 ITEv7 – Packet Tracer Lab Answers
 NE 2.0 – Lab Answers
 NE 2.0 Packet Tracer Activity Lab Answers
 NS 1.0 – Lab Answers
 NS 1.0 – Packet Tracer Activity Lab Answers
 Uncategorized
 Yoga
Copyright © 2021 InfraExam 2021.
We'd like to notify you about the latest updates
You can unsubscribe from notifications anytime

You might also like