Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.
description
Transcript of Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.
![Page 1: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/1.jpg)
Python OverviewInstallation, Sample Usage, Strings and OOP
Telerik Software Academyhttp://academy.telerik.com
Software Quality Assurance
![Page 2: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/2.jpg)
Table of Contents
Installing and Running Python Fundamentals of Python
development Data types Control structures: loops,
conditionals Functions Object-oriented programming
![Page 3: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/3.jpg)
Installing PythonOn MAC, Linux and Windows
![Page 4: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/4.jpg)
Installing Python
On MAC Homebrew can be used$ brew install python
On Linux Part of Linux is built with Python, so it
comes out-of-the-box On Windows
Download the installer from https://www.python.org/
Add the installation path to System Variables $PATH
![Page 5: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/5.jpg)
Installing Python on Windows and MAC
Live Demo
![Page 6: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/6.jpg)
Running Python Open the CMD/Terminal and run: You can run python code:
Print the numbers from 0 to 4
$ python
for i in range(5): print(i)
sum = 0for i in range(5, 10): sum += Iprint(sum)
Sum the numbers from 5 to 9
Significant whitespace matters
a lot
![Page 7: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/7.jpg)
Significant Whitespace
Significant whitespace is a way to write code in python This is actually the identation
Significant whitespace creates blocks in python code It is the equivalent of curly brackets
({ }) in other languages
![Page 8: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/8.jpg)
Python FundamentalsData types, Control Structures and
more
![Page 9: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/9.jpg)
Python Fundamentals
Python supports all the primary data types: int - integer numbers
int(intAsString) parses a string to int float - floating-point numbers
float(floatAsString) parses a string to float
none – like null bool – Boolean values (True and
False)
![Page 10: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/10.jpg)
Data TypesLive Demo
![Page 11: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/11.jpg)
Control Structures Python supports conditionals:if conditionOne: # run code if conditionOne is Trueelif conditionTwo: # run code if conditionOne is False # but conditionTwo is Trueelse # run code if conditionOne and # conditionTwo are False
The conditions are True-like and False-like i.e. "String", 0, none are evaluated to
True While ""(empty string), any number or
object are evaluated to False
![Page 12: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/12.jpg)
Conditional StatementsLive Demo
![Page 13: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/13.jpg)
Loops There are two types of loops in Python for loopfor i in range(5):
# run code with values of i: 0, 1, 2, 3 and 4
names = ['Doncho', 'Asya', 'Evlogi', 'Nikolay', 'Ivaylo']for i in range(len(names)): print('Hi! I am %s!'%names[i]);
while loopnumber = 1024binNumber = '';while number >= 1: binNumber += '%i'%(number%2) number /= 2print(binNumber[::-1])
![Page 14: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/14.jpg)
LoopsLive Demo
![Page 15: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/15.jpg)
Functions in PythonSeparate the code in smaller and
reusable pieces
![Page 16: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/16.jpg)
Functions in Python Functions in Python:
Are defined using the keyword "def" Have an identifier A list of parameters A return type
def toBin(number): bin = '' while number >= 1: bin += '%i'%(number%2) number /= 2 return bin[::-1]
![Page 17: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/17.jpg)
Functions in PythonLive Demo
![Page 18: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/18.jpg)
Modules in PythonHow to separate the code in different
modules
![Page 19: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/19.jpg)
Modules in Python Python applications are separated
into modules These module represent just a list of
functions and or classes To use all functions from a module numeralSystems:
import numeralSystemsprint(numeralSystems.toBin(1023))print(numeralSystems.toHex(1023))
from numeralSystems import toBin as bin
A single function:
Or some functionsfrom numeralSystems import toBin as bin, toHex as hex
![Page 20: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/20.jpg)
Modules in PythonLive Demo
![Page 21: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/21.jpg)
Classes and OOP
![Page 22: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/22.jpg)
Classes and OOP
Python has classes and inheritance
class Person: lastPersonId = 0 def __init__(self, name): self.__id = ++lsatPersonId self.__name = name def getId(): return self.__id def getName(): return self.__name def setName(newName): self.__name = newName
![Page 23: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/23.jpg)
Classes and OOPLive Demo
![Page 24: Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.](https://reader034.fdocuments.us/reader034/viewer/2022051007/5a4d1b3e7f8b9ab05999fb58/html5/thumbnails/24.jpg)
форум програмиране, форум уеб дизайнкурсове и уроци по програмиране, уеб дизайн – безплатно
програмиране за деца – безплатни курсове и уроцибезплатен SEO курс - оптимизация за търсачки
уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop
уроци по програмиране и уеб дизайн за ученициASP.NET MVC курс – HTML, SQL, C#, .NET, ASP.NET MVC
безплатен курс "Разработка на софтуер в cloud среда"
BG Coder - онлайн състезателна система - online judge
курсове и уроци по програмиране, книги – безплатно от Наков
безплатен курс "Качествен програмен код"
алго академия – състезателно програмиране, състезанияASP.NET курс - уеб програмиране, бази данни, C#, .NET, ASP.NET
курсове и уроци по програмиране – Телерик академия
курс мобилни приложения с iPhone, Android, WP7, PhoneGapfree C# book, безплатна книга C#, книга Java, книга C# Дончо Минков - сайт за програмиране
Николай Костов - блог за програмиранеC# курс, програмиране, безплатно
?? ? ?
??? ?
?
? ?
??
?
?
? ?
Questions?
?
Python Overview
http://academy.telerik.com