0% found this document useful (0 votes)
17 views

Week 2-FAQs

Uploaded by

rohitha vusa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Week 2-FAQs

Uploaded by

rohitha vusa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

WEEK-2 FAQs

General- FAQs

1. How to install spyder


Ans.
● To install spyder, through – ANACONDA NAVIGATOR, click on the link
below: -
https://repo.anaconda.com/archive/
● Next choose the version based on the OS:
● Click on the version to download
● Post the download, run the setup file
● Set the path
● Open the ANACONDA NAVIGATOR - ​Launch​ spyder

2. How to download slide lectures?


Ans. You will find the lecture slides under the relevant week.

3. How to download lecture videos?


Ans. You will find the lecture videos under the ​Download Videos​ tab.

Sequence Data Types

1. In a list the sub level component index starts from 0 and the inner level elements
start from 0 or 1…?
Ans. In python indexing starts from 0 to n-1. For sub level as well it starts from 0

2. Like tuple can we find out the length of the list?


Ans. Yes! We can find out the length of the list using ​len()

3. When List_1 is concatenated with List_2 , does the length of the List_1 change?
Ans. The length of the List_1 will not change unless you update it in the existing list. If
we assign it to a new variable length of the list changes depending on the number of
elements.

4. Can we find max and min for a tuple?


Ans.​ ​Yes! We can find maximum and minimum value for a tuple using max() and min()
function.But the only condition is the values of the tuple should have the same datatype.
5. Is a list mutable or immutable and can its values be changed?.
Ans. List is mutable, we can change the value.

6. ​How does one change the name of the key once assigned?.
Ans. Keys cannot be changed. You need to add a new key with the modified value then
remove the old one, or create a new dictionary with a new dictionary key.

7. ​ o insert an element in a list can we use ​append()​ instead of ​insert()?​


T
Ans. ​append​() can also be used. But it basically adds the element at the end. To add it in
the specified position you can use the ​insert().​

8. I​ f an element occurs twice or thrice, does ​remove​ method remove all occurrences or
only the first occurrence?
Ans. ​remove ​method removes only the first occurrence of the value.

9. Is List a type of Data?


Ans. There are four collection data types in the Python programming language.
List is a collection which is ordered and changeable. Allows duplicate members.

10. How to change a particular element in tuple ?


Ans. Tuples are immutable, you cannot modify them once created.

11. ​ an slicing be used on lists or only on tuples?


C
Ans. Slicing can be used in lists as well.

12. ​ hat if more than 2 words are repeated and we want to remove the word more
W
than 2 so how can we use the​ remove()​?
Ans. Kindly write a loop and execute the statements.

13. Why do we use dict_values? can we get simply the values.


Ans. Dictionary can be accessed by calling the key() or values(). Suppose we want to get
only values without dict_values, use the command list(dictionary_name.values())

14. ​ hen I created a dictionary, The order in which I am creating and the order in
W
which it prints is different.
Ans. Dictionary will have key value pairs and stored in an unordered manner.
15. What makes tuples different from lists?
Ans. In lists you can add, modify and delete the elements.
Once tuple is created you will not be able to modify the elements.

16. Can we update the sub level list directly??ex. id[1]=3.


Ans.Yes! you can also do that. It automatically gets updated in the main list

17. What is a ​Set?​


Ans. ​Set i​ s a collection which is unordered and unindexed. And it returns no duplicate
members. So when you print the values of Set, you won’t get it in the same order as you
have created.

18. Explain ​immutability?​


Ans. Once an object is created you will not be able to modify the elements, that refers to
immutability.

19. We print the combine tuple directly then it'll do any changes in the database ?I
mean it will store the data forever or just will store on a temporary basis?
Ans.Combined tuple will be printed but it will not be updated.
You can store the combined tuple in variable for future purpose.

20. ​Can we remove more than one object from a list?


Ans.Yes! We can remove multiple elements. Kindly write a loop and remove the
elements.

21. How to use insert() in case of negative indexing? Does insert() function have positive
indexing as default?​.
Ans.Instead of positive indexing you can also specify the negative indexing value.

22. When we use a ​pop​ method whether it will print the pop element or not.
Ans. The ​pop()​ method removes the item at the given index and returns the removed
item.
23. What is meant by ​String ​in python?
Ans. A string is a sequence of one or more characters (letters, numbers, symbols) that can
be either a constant or a variable. Made up of Unicode, strings are immutable sequences

24. ​How to create ​Strings​?


Ans. To create a string, enclose a sequence of characters inside single, double, triple
quotes Example: strSample = 'learning’

25. How to print strings?


Ans. We can print out strings by simply calling the print() function

26. ​What is ​range()​ in python?


Ans.​ range()​ is a built-in function of Python. It is used when a user needs to perform an
action for a specific number of times.

27. ​Where do we use ​range()​ in general?


Ans.​ range()​ is commonly used for looping hence, knowledge of the same is key
aspect when dealing with any kind of Python code.

28. ​ ow does ​range()​ work?


H
Ans. ​range()​ takes mainly three arguments
start: integer starting from which the sequence of integers is to be returned
stop: integer before which the sequence of integers is to be returned
The range of integers end at stop – 1.
step: integer value which determines the increment between each integer in the sequence

Numpy

1. How to access two columns from an array at a time ?


Ans. To access the columns from the array please use the below code
a[:,0:2] ---> to access first and 2nd column

2. To add a new array to an existing array ,I have used the below code
np.append(a,[[10,11,14]],axis=0)
But it added in the end ,why?
Ans. It is due to the ​append f​ unction.
​append a​ dds the value at the end of the array.
3. How do we know whether it is positive indexing or negative indexing ? Is there any
command to know about indexing?
Ans. The positive index starts from 0 to n-1 (with positive sign)
Negative indexing is used to access elements from the end of a list
negative indexing starts from -1 to -(n) (with negative sign)

4. What does ":" mean while accessing the subset of the array?
Ans. The ​:​ operator slices a part from a sequence object such as list, tuple or string. It
takes two arguments. First is the index of the start of slice and second is index of end
of slice. Both operands are optional. If the first operand is omitted, it is 0 by default.
If the second is omitted, it is set to the end of the sequence.
Example:
a=[1,2,3,4,5,6,7]
a[1:3]
[2, 3]

5. Why do we need to use the axis in insert() and delete() function?


Ans.delete() function is not available in python only del() is available and there is no
axis in the insert() and del() function.
The insert() function takes two parameters:
● index - position where an element needs to be inserted
● element - this is the element to be inserted in the list

del() - The del keyword is used to delete objects. You can pass the variable name with
the index value inside the braces.

6. ​Why are we using axis while inserting an array?.


Ans. To insert the new array along row wise we will use axis=0 and to add along
column wise use axis=1.

You might also like