1.What will the following code output?
>>> word=βabcdefghijβ
>>> word[:3]+word[3:]
The output is βabcdefghijβ. The first slice gives us βabcβ, the next gives us βdefghijβ.
2.How will you convert a list into a string?
We will use the join() method for this.
>>> nums=['one','two','three','four','five','six','seven']
>>> s=' '.join(nums)
>>> s
βone two three four five six sevenβ
3. How will you remove a duplicate element from a list?
We can turn it into a set to do that.
>>> list=[1,2,1,3,4,2]
>>> set(list)
{1, 2, 3, 4}
4. Explain the //, %, and ** operators in Python.
The // operator performs floor division. It will return the integer part of the result on division.
>>> 7//2
3
Normal division would return 3.5 here.
Similarly, ** performs exponentiation. a**b returns the value of a raised to the power b.
>>> 2**10
1024
Finally, % is for modulus. This gives us the value left after the highest achievable division.
>>> 13%7 6
5. Explain identity operators in Python.
The operators βisβ and βis notβ tell us if two values have the same identity. 1.
>>> 10 is '10' False >>> True is not False True
6. What are numbers?
Python provides us with five kinds of data types:
Numbers β Numbers use to hold numerical values.
>>> a=7.0
7. What are Strings?
A string is a sequence of characters. We declare it using single or double
quotes.
>>> title="Ayushi's Book"
8. What are Lists?
Lists β A list is an ordered collection of values, and we declare it using square brackets.
>>> colors=['red','green','blue']
>>> type(colors)
<class βlistβ>
9. What are Tuples?
Tuples β A tuple, like a list, is an ordered collection of values. The difference. However, is that a tuple is immutable. This means that we cannot change a value in it.
>>> name=(‘Ayushi’,’Sharma’) β¨
>>> name[0]=’Avery’ β¨
Traceback (most recent call last):
File β<pyshell#129>β, line 1, in <module>
name[0]=βAveryβ
TypeError: βtupleβ object does not support item assignment
10. What are Disctionary?
Dictionary β A dictionary is a data structure that holds key-value pairs. We
declare it using curly braces.
>>> squares={1:1,2:4,3:9,4:16,5:25}
>>> type(squares)
<class βdictβ>β¨1. >>> type({})
<class βdictβ>β¨We can also use a dictionary comprehension:
>>> squares={x:x**2 for x in range(1,6)}
>>> squares {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
The Data Monk services
We are well known for our interview books and have 70+ e-book across Amazon and The Data Monk e-shop page . Following are best-seller combo packs and services that we are providing as of now
- YouTube channelΒ covering all the interview-related important topics in SQL, Python, MS Excel, Machine Learning Algorithm, Statistics, and Direct Interview Questions
Link βΒ The Data Monk Youtube Channel - Website βΒ ~2000 completed solved Interview questions in SQL, Python, ML, and Case Study
Link βΒ The Data Monk website - E-book shop βΒ We have 70+ e-books available on our website and 3 bundles covering 2000+ solved interview questions.Β Do check it out
Link βΒ The Data E-shop Page - Instagram Page βΒ It covers only Most asked Questions and concepts (100+ posts). We have 100+ most asked interview topics explained in simple terms
Link βΒ The Data Monk Instagram page - Mock Interviews/Career Guidance/Mentorship/Resume Making
Book a slot on Top Mate
The Data Monk e-books
We know that each domain requires a different type of preparation, so we have divided our books in the same way:
1. 2200 Interview Questions to become Full Stack Analytics Professional β 2200 Most Asked Interview Questions
2.Data Scientist and Machine Learning Engineer -> 23 e-books covering all the ML Algorithms Interview Questions
3. 30 Days Analytics Course β Most Asked Interview Questions from 30 crucial topics
You can check out all the other e-books on our e-shop page β Do not miss it
For any information related to courses or e-books, please send an email to nitinkamal132@gmail.com