Professional Documents
Culture Documents
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 = []
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:
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
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]
>>> combo_list
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.sort()
>>> alpha_list
Now there is a got-cha above. Can you see it? Let’s do one more example to make it obvious:
>>> 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.
>>> 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:
[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:
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?
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:
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:
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:
Article Rating
Subscribe
{}[+]
0 COMMENTS
Search this website
CCNA1 v7
CCNA2 v7
CCNA3 v7