about the book computer science and informatics practices ... · 9789351101406 python cookbook, 3rd...
TRANSCRIPT
SHROFF PUBLISHERS &DISTRIBUTORS PVT. LTD.
Computer Science w
ith Python for CBSE Class XIISBN: 978-93-5213-762-6
First Edition/2018/Paperback/English
MRP: ` 325.00
Dr. Ashwin I. Mehta
Dr. Mehta
Computer Science and Informatics Practices
Pythonfor
with
Class XI
About the AuthorDr. Ashwin I. Mehta is M.Sc. from University of Mumbai and Ph.D. from Bhabha Atomic Research Centre in the Nuclear Physics Division (BARC) under the guidance of late Dr. N. Satyamurthy and Dr. K. Usha Dennis. His earliest encounter with computers was writing programs in FORTRAN with BESM-6 mainframe machine and later PDP-11. Subsequently he joined Halliburton and was involved in various technologies of data acquisition, storing and interpretation of oil field data. At Halliburton, he worked in Kuwait, Italy, United States of America and many other countries across the globe. He has several research papers to his credit in national and international journals. After leaving behind a hectic lifestyle in the oil field, he entered Information Technology (I.T.) academics. Since then, his interests include programming languages, web technologies, design architecture, big data and Python. He has 20+ years of experience that includes corporate training in Halliburton as well as in different academic institutions. He has authored a number of books including “Data Warehousing for beginners”, “Web Technologics” and “Advanced Java” published by Shroff Publishers and Distributors Pvt. Ltd. and “Python Programming” published by Himalaya Publications. Dr. Mehta can be contacted at [email protected] for your valuable comments and suggestions.
About the BookThis book will introduce CBSE class xi students to the coding skills of Python language and RDBMS operations. It is aimed at beginning computer user to learn first computer programming language as Python. If students have some previous programming experience in any formal computer language, his skill set will be enhanced further. The book is introduction to all topics of the syllabus, taking small steps from the basics to more involved and varied topics. I have mixed tutorials, guide, Q&A, cookbook and pocket reference styles to explain new terms and ideas. I have also taken care that not too many new concepts are introduced at once. In our examination system, often definitions of basic terms are asked. Most exam oriented definitions have been given in bold letters. Many topics where students are expected to answer pointwise, explanations have been given with bullets. All codes, given here, have been run and successful output have been checked. Some selected examples have been presented with screen shot, which should give students confidence of running these programs on their own. Even though this is an introduction, I include some topics that might seem advanced. For example, NoSQL databases, and variable length arguments (tuple) in Python. These topics have been included because they can solve some problems in easier way. Theoretical concept of computer architecture, scales of data, and cloud, with cyber laws and ethical online behavior are discussed. This book is for students, teachers, and professionals for computing language and RDBMS. The book does not require previous knowledge of any computing language except some mathematical skills are essential. The book has been divided in to four separate units as the syllabus. This will help to prepare for examinations.
Computer Science and Informatics Practices
Pythonfor
with
Class XI
Dr. Ashwin I. MehtaM.Sc. (University of Mumbai),
Ph. D. (Bhabha Atomic Research Centre)Ismail Yusuf College and Vissicomp Technology
Computer Science and Informatics Practices
Pythonfor
with
Class XI
Computer Science and Informatics Practices with Python for CBSC Class XI by Dr. Ashwin I. Mehta
Copyright © 2018, Dr. Ashwin I. Mehta
First Print: September 2018
ISBN: 978-93-5213-762-6
All rights reserved. No part of the material protected by this copyright notice may be reproduced or utilized in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage and retrieval system, nor exported, without the written permission of the copyright owner or the publisher.
Published by Shroff Publishers & Distributors Pvt. Ltd. B-103, Railway Commercial Complex, Sector 3, Sanpada (E), Navi Mumbai 400705 • TEL: (91 22) 4158 4158 • FAX: (91 22) 4158 4141\ E - m a i l : s p d o r d e r s @ s h r o f f p u b l i s h e r s . c o m • We b : w w w. s h r o f f p u b l i s h e r s . c o m Printed at Decora Book Prints Pvt. Ltd., Mumbai.
Acknowledgments
At the outset, I am extremely grateful to Shree Azizbhai Shroff of Shroff Publications Pvt. Ltd. for asking me to write this book and placing faith in me. It is an honour bestowed upon me by an established publisher. Right from the beginning, a vast amount of literature and references were made available to me very rapidly.
I wish to thank Dr. Swati Wahval, Principal, Ismail Yusuf College, Mr. Prakash Karani, Director, Vissicomp Technology, my student Miss Pooja Umeshchand Agrahari, my family members, in particular my wife Bhavna, my son, Kunjal, and my daughter Binkal; without their support, the book would not have become a reality.
I would like to take this opportunity to thank Mr. Prakash Karani, Director of Vissicomp Technologies Pvt. Ltd, who always motivated and inspired me with his leadership. I would also like to thank the staff and other faculty members at Vissicomp Technologies Pvt. Ltd, especially my student Miss Puja, who went through the initial draft of some chapters. I thank Sharmila Ramnani for meticulously going through the manuscript.
Finally, I would fail in my duty if I do not thank the staff at Shroff Publications who painstakingly prepared the book. Special thanks for cooperation and coordination to Mr. Sunil Shastri, Mr. Vishwajeet Sarmalkar, Mr. Vikas Kasalkar and Mr. Grudas Sawant.
I would like to acknowledge that many diagrams were taken from ‘Wikipedia’ and a significant amount of missing information was obtained by ‘Googling’. Some material is taken from my book ‘Python Programming’ published by Himalaya Publications.
Unit 1 ................................................................................... 1
Chapter 1 Why Learn Python .....................................................................3
Chapter 2 Installing Python ........................................................................7
Chapter 3 Data Types ..............................................................................13
Chapter 4 Conditional Programming if-elif-else .......................................27
Chapter 5 String .......................................................................................35
Chapter 6 List ...........................................................................................47
Chapter 7 Bubble Sort Algorithm .............................................................63
Unit 2 ................................................................................. 69
Chapter 1 Basic Computer Organization .................................................71
Chapter 2 Information Representation ....................................................81
Chapter 3 Program ...................................................................................85
Chapter 4 The Cloud ................................................................................91
Unit 3 ................................................................................. 97
Chapter 1 Basics of Relational Databases ...............................................99
Chapter 2 NoSQL Database ..................................................................105
Unit 4 ............................................................................... 109
Chapter 1 Internet Browsing Safety .......................................................111
Practicals ......................................................................... 117
Practicals ................................................................................................119
ContentComputer Science
viii Content
Informatics Practices
Unit 1-Refer to Unit 2 of Computer Science Section
Unit 2 ............................................................................... 133
Chapter 1 Python Data Structure: Pandas .............................................135
Unit 3-Refer to Unit 3 of Computer Science Section
Unit 4-Refer to Unit 4 of Computer Science Section
Practicals on Pandas ....................................................... 157Practicals on Pandas ..............................................................................159
SQL Database Management Practicals .................................................171
w w w . s h r o f f p u b l i s h e r s . c o m
S H R O F F P U B L I S H E R S & D I S T R I B U T O R S P V T . L T D . O R D E R F O R M
I S B N T i t l e A u t h o rY e a r o f
P u b l i c a t i o nP r i c e O r d e r
9 7 8 9 3 5 2 1 3 5 9 7 4 A n I n t r o d u c t i o n t o P y t h o n G u i d o V a n R o s s u m 2 0 1 7 3 0 0 . 0 0
9 7 8 9 3 5 2 1 3 4 7 5 5 T h i n k P y t h o n , 2 n d E d i t i o n A l l e n B . D o w n e y 2 0 1 7 4 7 5 . 0 0
9 7 8 9 3 5 2 1 3 6 2 7 8 P y t h o n f o r E v e r y b o d y C h a r l e s S e v e r a n c e 2 0 1 7 5 0 0 . 0 0
9 7 8 9 3 5 2 1 3 6 8 1 0 P r a c t i c a l P r o g r a m m i n g , 3 r d E d i t i o n P a u l G r i e s 2 0 1 8 6 0 0 . 0 0
9 7 8 8 1 8 4 0 4 8 7 6 6 H e a d F i r s t P r o g r a m m i n g D a v i d G r i f fi t h s 2 0 0 9 9 5 0 . 0 09 7 8 9 3 5 2 1 3 4 8 2 3 H e a d F i r s t P y t h o n , 2 n d E d i t i o n P a u l B a r r y 2 0 1 7 9 5 0 . 0 0
9 7 8 9 3 5 2 1 3 5 4 0 0 P y t h o n i n a N u t s h e l l , 3 r d E d i t i o n A l e x M a r t e l l i 2 0 1 7 1 , 5 0 0 . 0 0
9 7 8 9 3 5 1 1 0 1 4 0 6 P y t h o n C o o k b o o k , 3 r d E d i t i o n B r i a n J o n e s 2 0 1 3 1 , 1 7 5 . 0 09 7 8 9 3 5 1 1 0 2 0 1 4 L e a r n i n g P y t h o n , 5 t h E d i t i o n M a r k L u t z 2 0 1 3 1 , 6 0 0 . 0 09 7 8 9 3 5 0 2 3 2 8 7 3 P r o g r a m m i n g P y t h o n , 4 t h E d i t i o n M a r k L u t z 2 0 1 1 1 , 4 0 0 . 0 09 7 8 9 3 5 1 1 0 8 7 8 8 I n t r o d u c i n g P y t h o n B i l l L u b a n o v i c 2 0 1 4 9 0 0 . 0 09 7 8 9 3 5 2 1 3 4 3 5 9 T h e H i t c h h i k e r ’ s G u i d e t o P y t h o n T a n y a S c h l u s s e r 2 0 1 6 6 2 5 . 0 0
9 7 8 8 1 8 4 0 4 7 4 8 6 N a t u r a l L a n g u a g e P r o c e s s i n g w i t h P y t h o n E d w a r d L o p e r 2 0 0 9 9 5 0 . 0 0
9 7 8 8 1 8 4 0 4 8 9 8 8 B i o i n f o r m a t i c s P r o g r a m m i n g U s i n g P y t h o n M i t c h e l l L . M o d e l 2 0 1 0 1 0 2 5 . 0 0
9 7 8 8 1 8 4 0 4 5 8 3 3 P y t h o n f o r U n i x a n d L i n u x S y s t e m A d m i n i s t r a t i o n N o a h G i f t 2 0 0 8 8 5 0 . 0 0
9 7 8 9 3 5 1 1 0 3 8 5 1 P y t h o n a n d H D F 5 A n d r e w C o l l e t t e 2 0 1 3 2 7 5 . 0 0
9 7 8 9 3 5 2 1 3 6 0 5 6 E l e g a n t S c i P y J u a n N u n e z -I g l e s i a s 2 0 1 7 7 5 0 . 0 0
9 7 8 9 3 5 0 2 3 9 6 3 6 S c i P y a n d N u m P y E l i B r e s s e r t 2 0 1 3 2 5 0 . 0 0
9 7 8 9 3 5 2 1 3 6 4 1 4 P y t h o n f o r D a t a A n a l y s i s , 2 n d E d i t i o n W e s M c K i n n e y 2 0 1 7 1 4 5 0 . 0 0
9 7 8 9 3 5 0 2 3 7 6 6 3 P r o g r a m m i n g C o m p u t e r V i s i o n w i t h P y t h o n J a n E r i k S o l e m 2 0 1 2 5 2 5 . 0 0
9 7 8 9 3 5 1 1 0 2 9 6 0 T h i n k B a y e s A l l e n B . D o w n e y 2 0 1 3 5 0 0 . 0 09 7 8 9 3 5 2 1 3 2 9 6 6 E s s e n t i a l S Q L A l c h e m y , 2 n d E d i t i o n R i c k C o p e l a n d 2 0 1 6 4 0 0 . 0 0
9 7 8 9 3 5 1 1 0 9 9 7 6 C y t h o n : A G u i d e f o r P y t h o n P r o g r a m m e r s K u r t W . S m i t h 2 0 1 5 5 0 0 . 0 0
s p d o r d e r s @ s h r o f f p u b l i s h e r s . c o m
9 7 8 9 3 5 2 1 3 4 5 7 1I n t r o d u c t i o n t o M a c h i n e L e a r n i n g w i t h P y t h o n : A G u i d e f o r D a t a S c i e n t i s t s
A n d r e a s C . M ü l l e r 2 0 1 6 1 2 0 0 . 0 0
9 7 8 9 3 5 2 1 3 4 2 9 8 D a t a V i s u a l i z a t i o n w i t h P y t h o n a n d J a v a S c r i p t K y r a n D a l e 2 0 1 6 9 0 0 . 0 0
9 7 8 9 3 5 2 1 3 4 4 5 8 T h i n k D S P : D i g i t a l S i g n a l P r o c e s s i n g i n P y t h o n A l l e n B . D o w n e y 2 0 1 6 3 2 5 . 0 0
9 7 8 9 3 5 2 1 3 4 3 4 2 F o u n d a t i o n s f o r A n a l y t i c s w i t h P y t h o n
C l i n t o n W . B r o w n l e y 2 0 1 6 6 5 0 . 0 0
9 7 8 9 3 5 2 1 3 4 0 3 8 P r o g r a m m i n g G o o g l e A p p E n g i n e w i t h P y t h o n D a n S a n d e r s o n 2 0 1 6 9 0 0 . 0 0
9 7 8 9 3 5 2 1 3 3 3 5 2 D a t a W r a n g l i n g w i t h P y t h o n J a c q u e l i n e K a z i l 2 0 1 6 8 5 0 . 0 09 7 8 9 3 5 2 1 3 3 0 5 5 H i g h P e r f o r m a n c e P y t h o n M i c h a G o r e l i c k 2 0 1 6 7 2 5 . 0 0
9 7 8 9 3 5 2 1 3 6 9 9 5 F l a s k W e b D e v e l o p m e n t , 2 n d E d i t i o n M i g u e l G r i n b e r g 2 0 1 8 7 5 0 . 0 0
9 7 8 9 3 5 1 1 0 6 3 0 2 P y t h o n P o c k e t R e f e r e n c e , 5 t h E d i t i o n M a r k L u t z 2 0 1 4 4 0 0 . 0 0
9 7 8 9 3 5 0 2 3 8 0 3 5 T h i n k C o m p l e x i t y A l l e n B . D o w n e y 2 0 1 2 3 2 5 . 0 09 7 8 9 3 5 0 2 3 7 2 0 5 I n t r o d u c t i o n t o T o r n a d o A d a m P a r r i s h 2 0 1 5 2 5 0 . 0 0
9 7 8 9 3 5 0 2 3 1 9 1 3 R e a l W o r l d I n s t r u m e n t a t i o n w i t h P y t h o n J o h n M . H u g h e s 2 0 1 0 9 7 5 . 0 0
9 7 8 8 1 8 4 0 4 1 8 5 9 D a t a C r u n c h i n g G r e g W i l s o n 2 0 0 5 2 5 0 . 0 09 7 8 9 3 5 2 1 3 2 0 5 8 F l u e n t P y t h o n L u c i a n o R a m a l h o 2 0 1 5 1 , 2 7 5 . 0 0
9 7 8 9 3 5 2 1 3 7 1 5 2 W e b S c r a p i n g w i t h P y t h o n , 2 n d E d i t i o n R y a n M i t c h e l l 2 0 1 8 7 5 0 . 0 0
9 7 8 9 3 5 2 1 3 6 1 6 2 T e s t - D r i v e n D e v e l o p m e n t w i t h P y t h o n , 2 n d E d i t i o n
H a r r y J . W . P e r c i v a l 2 0 1 7 1 , 7 2 5 . 0 0
9 7 8 9 3 5 2 1 3 4 9 1 5 P y t h o n D a t a S c i e n c e H a n d b o o k J a k e V a n d e r P l a s 2 0 1 7 1 , 2 5 0 . 0 0
9 7 8 9 3 5 2 1 3 4 9 2 2 M u r a c h ’ s P y t h o n P r o g r a m m i n g M i c h a e l U r b a n 2 0 1 7 8 0 0 . 0 0
9 7 8 9 3 5 1 1 0 8 0 2 3 C r e a t i n g A p p s i n K i v y D u s t y P h i l l i p s 2 0 1 4 3 7 5 . 0 09 7 8 9 3 5 2 1 3 0 9 6 2 D a t a S c i e n c e f r o m S c a r t c h J o e l G r u s 2 0 1 5 6 0 0 . 0 09 7 8 9 3 5 2 1 3 0 1 4 6 M o n g o d b a n d P y t h o n N i a l l O ’ H i g g i n s 2 0 1 5 2 5 0 . 0 09 7 8 9 3 5 1 1 0 8 7 4 0 P y t h o n a n d A W S C o o k b o o k M i t c h G a r n a a t 2 0 1 4 2 0 0 . 0 09 7 8 9 3 5 1 1 0 9 3 0 3 P y t h o n f o r F i n a n c e Y v e s H i l p s c h 2 0 1 4 1 , 2 0 0 . 0 0
9 7 8 9 3 5 2 1 3 5 1 2 7 T h o u g h t f u l M a c h i n e L e a r n i n g w i t h P y t h o n M a t t h e w K i r k 2 0 1 7 3 5 0 . 0 0
9 7 8 9 3 5 2 1 3 6 4 0 7 P r o g r a m m i n g w i t h M i c r o P y t h o n
N i c h o l a s H . T o l l e r v e y 2 0 1 7 4 7 5 . 0 0
SHROFF PUBLISHERS &DISTRIBUTORS PVT. LTD.
Computer Science w
ith Python for CBSE Class XI
ISBN: 978-93-5213-762-6
First Edition/2018/Paperback/English
MRP: ` 325.00
Dr. Ashwin I. Mehta
Dr. Mehta
Computer Science and Informatics Practices
Pythonfor
with
Class XI
About the AuthorDr. Ashwin I. Mehta is M.Sc. from University of Mumbai and Ph.D. from Bhabha Atomic Research Centre in the Nuclear Physics Division (BARC) under the guidance of late Dr. N. Satyamurthy and Dr. K. Usha Dennis. His earliest encounter with computers was writing programs in FORTRAN with BESM-6 mainframe machine and later PDP-11. Subsequently he joined Halliburton and was involved in various technologies of data acquisition, storing and interpretation of oil field data. At Halliburton, he worked in Kuwait, Italy, United States of America and many other countries across the globe. He has several research papers to his credit in national and international journals. After leaving behind a hectic lifestyle in the oil field, he entered Information Technology (I.T.) academics. Since then, his interests include programming languages, web technologies, design architecture, big data and Python. He has 20+ years of experience that includes corporate training in Halliburton as well as in different academic institutions. He has authored a number of books including “Data Warehousing for beginners”, “Web Technologics” and “Advanced Java” published by Shroff Publishers and Distributors Pvt. Ltd. and “Python Programming” published by Himalaya Publications. Dr. Mehta can be contacted at [email protected] for your valuable comments and suggestions.
About the BookThis book will introduce CBSE class xi students to the coding skills of Python language and RDBMS operations. It is aimed at beginning computer user to learn first computer programming language as Python. If students have some previous programming experience in any formal computer language, his skill set will be enhanced further. The book is introduction to all topics of the syllabus, taking small steps from the basics to more involved and varied topics. I have mixed tutorials, guide, Q&A, cookbook and pocket reference styles to explain new terms and ideas. I have also taken care that not too many new concepts are introduced at once. In our examination system, often definitions of basic terms are asked. Most exam oriented definitions have been given in bold letters. Many topics where students are expected to answer pointwise, explanations have been given with bullets. All codes, given here, have been run and successful output have been checked. Some selected examples have been presented with screen shot, which should give students confidence of running these programs on their own. Even though this is an introduction, I include some topics that might seem advanced. For example, NoSQL databases, and variable length arguments (tuple) in Python. These topics have been included because they can solve some problems in easier way. Theoretical concept of computer architecture, scales of data, and cloud, with cyber laws and ethical online behavior are discussed. This book is for students, teachers, and professionals for computing language and RDBMS. The book does not require previous knowledge of any computing language except some mathematical skills are essential. The book has been divided in to four separate units as the syllabus. This will help to prepare for examinations.