├── LICENSE ├── README.md ├── S03 ├── Exercise Calculate Area.txt ├── Exercise Converter Function.txt ├── Exercise String Concatenation.txt ├── Lecture 3-Storing-Functions.pdf └── Lecture-Storing-Functions.pdf ├── S04 ├── Sequences.mp4 └── Thumbs.db ├── S05 ├── Section-4.1.Solution.pdf ├── Section-4.1.pdf └── Thumbs.db ├── S06 ├── Exercise-KML-1.pdf ├── Solution-KML-1.pdf └── Thumbs.db └── S08 └── GUI-CSV-To-KML-Lecture.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Packt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python-for-Beginners-with-Examples 2 | Code Repository for Python for Beginners with Examples, published by Packt 3 | -------------------------------------------------------------------------------- /S03/Exercise Calculate Area.txt: -------------------------------------------------------------------------------- 1 | Exercise: Calculate Area 2 | 3 | Create a function that calculates and outputs the rectangle area given its two sides as function arguments. 4 | 5 | 6 | Solution: Calculate Area 7 | 8 | def rectangle(a, b): 9 | area = a * b 10 | return area 11 | 12 | #Calling the function using two sample values 13 | print(rectangle(2,3)) -------------------------------------------------------------------------------- /S03/Exercise Converter Function.txt: -------------------------------------------------------------------------------- 1 | Question 2 | Create a Python function that converts miles to kilometers. You can search the web to find out the conversion formula and then implement it in Python. 3 | 4 | Solution: Converter Function 5 | 6 | def miles_to_km(m): 7 | km = m * 1.60934 8 | return km 9 | 10 | #Then you can call the function using any value 11 | print(miles_to_km(10)) -------------------------------------------------------------------------------- /S03/Exercise String Concatenation.txt: -------------------------------------------------------------------------------- 1 | Exercise String Concatenation 2 | Create a function that takes two strings as arguments and concatenates them. Example Given the strings John and Smith, the function should output John Smith. 3 | 4 | Solution: String Concatenation 5 | 6 | def concatenate(s1, s2): 7 | s = s1 + " " + s2 8 | return s 9 | 10 | print(concatenate("John", "Smith")) -------------------------------------------------------------------------------- /S03/Lecture 3-Storing-Functions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Python-for-Beginners-with-Examples/96ec5a0541eea53198aed411908d8c799d41e139/S03/Lecture 3-Storing-Functions.pdf -------------------------------------------------------------------------------- /S03/Lecture-Storing-Functions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Python-for-Beginners-with-Examples/96ec5a0541eea53198aed411908d8c799d41e139/S03/Lecture-Storing-Functions.pdf -------------------------------------------------------------------------------- /S04/Sequences.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Python-for-Beginners-with-Examples/96ec5a0541eea53198aed411908d8c799d41e139/S04/Sequences.mp4 -------------------------------------------------------------------------------- /S04/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Python-for-Beginners-with-Examples/96ec5a0541eea53198aed411908d8c799d41e139/S04/Thumbs.db -------------------------------------------------------------------------------- /S05/Section-4.1.Solution.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Python-for-Beginners-with-Examples/96ec5a0541eea53198aed411908d8c799d41e139/S05/Section-4.1.Solution.pdf -------------------------------------------------------------------------------- /S05/Section-4.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Python-for-Beginners-with-Examples/96ec5a0541eea53198aed411908d8c799d41e139/S05/Section-4.1.pdf -------------------------------------------------------------------------------- /S05/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Python-for-Beginners-with-Examples/96ec5a0541eea53198aed411908d8c799d41e139/S05/Thumbs.db -------------------------------------------------------------------------------- /S06/Exercise-KML-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Python-for-Beginners-with-Examples/96ec5a0541eea53198aed411908d8c799d41e139/S06/Exercise-KML-1.pdf -------------------------------------------------------------------------------- /S06/Solution-KML-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Python-for-Beginners-with-Examples/96ec5a0541eea53198aed411908d8c799d41e139/S06/Solution-KML-1.pdf -------------------------------------------------------------------------------- /S06/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Python-for-Beginners-with-Examples/96ec5a0541eea53198aed411908d8c799d41e139/S06/Thumbs.db -------------------------------------------------------------------------------- /S08/GUI-CSV-To-KML-Lecture.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sat Sep 5 10:03:36 2015 4 | 5 | @author: Ardit Sulce 6 | """ 7 | 8 | import simplekml 9 | import pandas 10 | import tkinter 11 | from tkinter.filedialog import askopenfilename 12 | 13 | def browse(): 14 | global infile 15 | infile=askopenfilename() 16 | 17 | def kmlFunction(outfile="C:\\out\\Coordinates.kml"): 18 | global infile 19 | if infile is None: 20 | infile=browse() 21 | df=pandas.read_csv(infile) 22 | kml=simplekml.Kml() 23 | for lon,lat in zip(df["Longitude"],df["Latitude"]): 24 | kml.newpoint(coords=[(lon,lat)]) 25 | kml.save(outfile) 26 | 27 | root=tkinter.Tk() 28 | root.title("KML Generator") 29 | label=tkinter.Label(root,text="This program generates a KML file out of a CSV") 30 | label.pack() 31 | browseButton=tkinter.Button(root,text="Browse",command=browse) 32 | browseButton.pack() 33 | kmlButton=tkinter.Button(root,text="Generate KML",command=kmlFunction) 34 | kmlButton.pack() 35 | root.mainloop() 36 | 37 | 38 | --------------------------------------------------------------------------------