Sunday, September 16, 2018

Python Ninja Bootcamp 13-Q&A First

Learn Python like a Professional! Take You from 0 to Hero




In this Python lecture, we will learn about the Q&A 1st.


Answer the following Question-


Q. Define String, List, Dictionary, Tuple, file.

Ans. String- String

        ListList

        DictionaryDictionary

        TupleTuple

        FileFile



Q. What is the type of 1+2.5+5?

type(1+2.5+5)
>> float



Q. Write a code to find the square root of a number using power operator?


4**0.5
>> 2


Q. How could you index ‘h’ from the string s=’Python’?

s = 'Python' 
print(s[3])
>> h


Q.Write the code to reverse the string s=’Python’?

s = 'Python' 
print(s[::-1])
>>nohtyp


Q.How would you reassign ‘Ninja’ in the place of ‘AI’ in list L=[1,2,3,[‘Python’,’Bootcamp’,[‘AI’,’ML’]]]?


L=[1,2,3,['Python','Bootcamp',['AI','ML']]]
print(L)
>> [1, 2, 3, ['Python', 'Bootcamp', ['AI', 'ML']]]

L[3][2][1]='Ninja'
print(L)
>> [1, 2, 3, ['Python', 'Bootcamp', ['AI', 'Ninja']]]


Q.How could you grab 'AI' from the Dictionary d = {'k1':{'k2':'AI'}}?


d = {'k1':{'k2':'AI'}}
print(d)
>> {'k1':{'k2':'AI'}}

print( d['k1']['k2'] )
>> 'AI'


Q.Write code to grab 'AI' from the d = {'k1':[{'k2':('ML',['AI'])}]}?


d = {'k1':[{'k2':('ML',['AI'])}]}
print(d)
>>d = { 'k1' : [ { 'k2' : ( 'ML' ,[ 'AI' ] ) } ] }


Q.Write code to grab 'AI' from the d = {'k1':[1,2,{'k2':['DS',{'ML':[1,2,['AI']]}]}]}?

d = {'k1':[1,2,{'k2':['DS',{'ML':[1,2,['AI']]}]}]}
print(d)
>> {'k1':[1,2,{'k2':['DS',{'ML':[1,2,['AI']]}]}]}

print( d['k1'][2]['k2'][1]['ML'][2][0] ) 
>> AI


Q.Find the unique values from the list l=[1,2,2,3,4,4,1,1,2,2,3,3,2]?


l=[1,2,2,3,4,4,1,1,2,2,3,3,2]
print(l)
>> [1, 2, 2, 3, 4, 4, 1, 1, 2, 2, 3, 3, 2]

print(set(l))
>> [1, 2, 2, 3, 4, 4, 1, 1, 2, 2, 3, 3, 2]


Q.What is the output of the expression 3.0==3?

print( 3.0==3 )
>> True


Q.What is the output of expression 4**0.5 != 2 ?

print(4**0.5 != 2 )
>> False


Q.What is the output of L1[3][1]<=L2[2]['k1'], if L1=[1,2,3,[4,5]] & L2=[6,5,{'k1':4}] ?


L1=[1,2,3,[4,5]] 
L2=[6,5,{'k1':4}] 


print( L1[3][1]<=L2[2]['k1'] )
>> False




EDITS ARE WELCOMED!!

In the next Blog, we will discuss Basic operators. 

https://sngurukuls247.blogspot.com/2018/09/python-ninja-bootcamp-14-comparison.html

......................................................................................................................................

Follow the link below to access Free Python Lectures-
https://www.youtube.com/channel/UCENc9qI7_r8KMf6-_1R1xnw


View the Jupyter Notebook for this lecture

Download the Jupyter Notebook for this lecture 



Join the FB group for Q&A  

Feel free contact me on-
Email - sn.gurukul24.7uk@gmail.com

4 comments:

  1. Then again, according to the report, the high introductory speculation, low access to financing, and the nonappearance of gifted specialists are among the central factors that may restrain the development of the market in anticipated years. ai courses

    ReplyDelete
  2. I’m happy I located this blog! From time to time, students want to cognitive the keys of productive literary essays composing. Your first-class knowledge about this good post can become a proper basis for such people. nice one

    Data Science Course

    ReplyDelete
  3. I recently came across your article and have been reading along. I want to express my admiration of your writing skill and ability to make readers read from the beginning to the end. I would like to read newer posts and to share my thoughts with you.

    Data Science Training

    ReplyDelete
  4. Register for python classes at AI Patasala to reap the benefits of the Python Course with Placements in Hyderabad and get a jump start on your new career.

    ReplyDelete