Presentation is loading. Please wait.

Presentation is loading. Please wait.

Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance.

Similar presentations


Presentation on theme: "Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance."— Presentation transcript:

1 Installation, Sample Usage, Strings and OOP Telerik Software Academy http://academy.telerik.com Software Quality Assurance

2  Installing and Running Python  Fundamentals of Python development  Data types  Control structures: loops, conditionals  Functions  Object-oriented programming

3 On MAC, Linux and Windows

4  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/ https://www.python.org/  Add the installation path to System Variables $PATH

5 Live Demo

6  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) print(i) sum = 0 for i in range(5, 10): sum += I sum += Iprint(sum)  Sum the numbers from 5 to 9 Significant whitespace matters a lot

7  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

8 Data types, Control Structures and more

9  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)

10 Live Demo

11  Python supports conditionals: if conditionOne: # run code if conditionOne is True # run code if conditionOne is True elif conditionTwo: # run code if conditionOne is False # run code if conditionOne is False # but conditionTwo is True # but conditionTwo is True else # 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

12 Live Demo

13  There are two types of loops in Python  for loop for i in range(5): # run code with values of i: 0, 1, 2, 3 and 4 # 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]); print('Hi! I am %s!'%names[i]);  while loop number = 1024 binNumber = ''; while number >= 1: binNumber += '%i'%(number%2) binNumber += '%i'%(number%2) number /= 2 number /= 2print(binNumber[::-1])

14 Live Demo

15 Separate the code in smaller and reusable pieces

16  Functions in Python:  Are defined using the keyword "def"  Have an identifier  A list of parameters  A return type def toBin(number): bin = '' bin = '' while number >= 1: while number >= 1: bin += '%i'%(number%2) bin += '%i'%(number%2) number /= 2 number /= 2 return bin[::-1] return bin[::-1]

17 Live Demo

18 How to separate the code in different modules

19  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 numeralSystems print(numeralSystems.toBin(1023))print(numeralSystems.toHex(1023)) from numeralSystems import toBin as bin  A single function:  Or some functions from numeralSystems import toBin as bin, toHex as hex

20 Live Demo

21

22  Python has classes and inheritance class Person: lastPersonId = 0 lastPersonId = 0 def __init__(self, name): def __init__(self, name): self.__id = ++lsatPersonId self.__id = ++lsatPersonId self.__name = name self.__name = name def getId(): def getId(): return self.__id return self.__id def getName(): def getName(): return self.__name return self.__name def setName(newName): def setName(newName): self.__name = newName self.__name = newName

23 Live Demo

24 форум програмиране, форум уеб дизайн курсове и уроци по програмиране, уеб дизайн – безплатно програмиране за деца – безплатни курсове и уроци безплатен 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, PhoneGap free C# book, безплатна книга C#, книга Java, книга C# Николай Костов - блог за програмиране http://academy.telerik.com


Download ppt "Installation, Sample Usage, Strings and OOP Telerik Software Academy Software Quality Assurance."

Similar presentations


Ads by Google