CCDA Python HandsOn IPRoute
CCDA Python HandsOn IPRoute
1
Variables, Data Types and Strings
1. Write Python code to take the following input from the user. Print them along with their data types.
a. vendor_name (e.g. 'cisco')
b. os_version (e.g. 6.1)
c. number_of_interfaces (e.g. 4)
Expected output:
a. vendor_name: cisco
type: <class 'str'>
b. os_version: 6.1
type: <class 'float'>
c. number_of_interfaces: 4
type: <class 'int'>
2. Write Python code to create a variable and store the following sting in it.
‘Cisco_IOS_XE_Dublin_17.10.x’. From this extract the version part and store in another variable called version.
Print version variable.
Expected output:
Version is 17.10.x
3. Write Python code to create a string variable and put the following string in it.
' this string has both leading and trailing spaces '
Find and print the number of leading as well as trailing spaces.
Expected output:
Leading spaces: 3
Trailing spaces: 4
Expected output:
2. Create another list variable called device_grps and make the above lists as elements of this list. (Hint: Use built-in
append method of lists)
2
Expected output:
3. Create another list variable called devices and print it which should give the following output.
4. We need to create a list of certified vendors and need to ensure that someone else should not be able to accidentally
modify that list. Currently the behavior is as follows:
We are able to modify the list and add additional vendor. Make appropriate change so that this cannot be done.
Output: “Your bill amount before discount is 1500 and after a discount of 10 % it is 1350.”
3
2. Create a list variable as shown below. Using for loop print only those elements of the list which are starting with vowels.
Expected output:
adam
edward
3. Ask the user to input number. Keep adding up the numbers he is entering until he enters zero and keep asking him to
enter the next number. (Hint: In addition to taking an input number form the user, we need to keep taking the input
number from him inside the while loop.)
4. Revisit problem 2 given above. Take the code to check whether an element of the list is starting with vowel or not and
move it into a function. While traversing the list using for loop, call the function written above to check whether current
element is starting with vowel or not.
Sample input and output remain same as in question 2, but code changes. You have to use a function.