124 0 2MB
![Python For Architects 1 [PDF]](https://vdoc.tips/img/200x200/python-for-architects-1.jpg)
Python Programming Chandra Hampiholi
 
 Contnents - Python Programming Contents for PYTHON - BASICS
 
 1: Introduction To Programming Why Code ? And Why code in Python ? Algorithmic Thinking What is Programming ? 2: Introduction To Python IDE & Python Shell Window “Hello World” Understanding Python variables Python basic Operators Understanding python Syntax 3: Python Data Types Numeric data types: int, float, complex Using string data type and string operations Defining list and list slicing Use of Tuple & Dictionaries data type 4: Python Program Flow Control Conditional blocks using if, else and elif Simple for loops in python For loops using ranges, string, lists and dictionaries Use of while loops in python Loop manipulation using pass, continue, break and else
 
 Contd .. 5: Python Functions, Modules And Packages Organizing python codes using functions Organizing python projects into modules Importing own module as well as external modules Understanding Packages Programming using functions, modules and external packages 6: Python String, List And Dictionary Manipulations Building blocks of python programs Understanding string in build methods List manipulation using in build methods Dictionary manipulation 7: Python File Operation Reading & writing files in python Understanding read functions, read(), readline() and readlines() Understanding write functions, write() and writelines() Manipulating file pointer using seek Programming using file operations 8: Python Object Oriented Programming – Oops Concept of class, object and instances Constructor, class attributes and destructors Use of class in live projects Inheritance , overlapping and overloading operators
 
 What isProgramming It is going to stay whether you like it or not There is a lot of people in the world who can program, but none that can also do what you know how to do So better to write you own program instead of instructing a programmer Great Example : No typist around, You Type your own letters…. Right ?
 
 So Start Coding … Automate your business processes !!!
 
 SLIDE
 
 3
 
 Basic Requirements 1. 2. 3. 4. 5. 6.
 
 Curiosity to learn Readiness to unlearn old ways Ample Time to practice A Laptop with Windows Anaconda or (Repl.it) Account Access to Internet
 
 If no internet, then can use 1. Pycharm or Atom (Free) 2. Visual Studio 2017 Community 3. VS-Code (Python Tools for VS)
 
 4. Python Interpreter(python.org)
 
 Coding : language of choice? As on Sep 2018
 
 IMPLEMENTATION OF PYTHON
 
 Cpython (Python written in C) IronPython (Python on .NET) Jython (Python on the Java VM) PyPy (fastpython with a JIT compiler) Stackless Python (Branch of CPython) MicroPython (Python on micro controllers) Anaconda Python (Python distribution for data management, analysis and visualization of large data sets) PythonAnywhere (freemium hosted Python installation which lets you run Python in the browser) PythonToolsForVS (Free- from Microsoft)
 
 LIBRARIES NumPy Numerical arrays & math functions. PyPlot For visualization tools.
 
 why python ? Python is Easy to learn & understand; almost English like .. Python is Flexible & Scalable & Portable to platforms Python works on many platforms : PC, Mac, Unix, Mobiles, Internet, etc.. Python is a general purpose programming language. Developing desktop, web, complex scientific & visualisation apps & also ML & AI • Python has a large open source community support & huge library • Of-course Python is FREE Hurray !!! • • • • •
 
 SLIDE
 
 5
 
 future of Python ? Why Python is so popular
 
 Machine Learning
 
 01
 
 Statistical techniques to give computer systems the ability to "learn" from data, without being explicitly programmed
 
 Artificial Intelligence
 
 02
 
 Artificial intelligence (AI) is an area of computer science that emphasizes the creation of intelligent machines that work and react like humans
 
 BIG Data
 
 03
 
 Making sense out of gigantic data that is available for the purpose of Business Intelligence
 
 Web Programming Excellent framework for web programming. dJango
 
 04
 
 API Programming
 
 05 SLIDE
 
 API is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other.
 
 6
 
 Compiled Language
 
 Vs
 
 Interpreted Language
 
 JAV A
 
 Interpreted Language Compiled Language
 
 type of Languages ?
 
 C#, C++
 
 Java C C # C + + Fortran SLIDE
 
 7
 
 Python Ruby Perl R Lisp
 
 PYTHON P H P, R U B Y PERL, R
 
 Who uses Python ? • • • • • • • • •
 
 Google….. You Tube.. .. Spotify…... FaceBook Reddit .. Instagram Quora Netflix Dropbox
 
 • Python is very mature … It is Scalable to any size and shape SLIDE
 
 8
 
 Algorithmic- Thinking An algorithm is an unambiguous description that makes clear what has to be done/ implemented.
 
 Examples :
 
 • In a recipe, a step such as “Bake until done” is ambiguous • Because it doesn’t explain what “done” means. • A more explicit way - “Bake until the cheese begins to bubble” An algorithm expects a defined set of inputs An algorithm produces a defined set of outputs. An algorithm must produce a result, stopping after a finite time An algorithms is guaranteed to produce the correct result.
 
 What is a - Program?
 
 It is a list of sequential instructions that tell a computer what to do
 
 Instructions to Computer
 
 Instructions to Human Flow direction of instructions
 
 Fill Kettle with water Boil water Get teapot Fill teapot with bags Fill with water Get cups Wait until ready Pour out Add Milk Serve Tea
 
 Sequential Operation Number
 
 100 : 200 : 300 : 400 : 500 : 600 : 700 : 800 : 900 : 1000 :
 
 !Fill Kettle with water !Boil water !Get teapot !Fill teapot with bags !Fill with water !Get cups !Wait until ready !Pour out !Add Milk !Serve Tea
 
 Colon Instructions Separation set to Computer
 
 What isProgramming Logical and unambiguous set of Instructions 200: !Boil water IF water (boiling) THEN (turn kettle off) ELSE CONTINUE (boil) 300: !Get teapot IF (number of people) less or equal to 2 THEN (GET smallteapot) IF (number of people) greater than 2 THEN (GET largeteapot) IF teapot (dirty) THEN (wash out teapot) UNTIL (clean) IF teapot (clean) THEN (swirl hot water) UNTIL (warm) IF teapot (warm) THEN (Fill teapot with bags) !continue 400: !Fill teapot with bags LET teatype=USERCHOOSE(EarlGrey,Lapsang,Camomile,Green) IF teapot (large) THEN add 2 teabag USING teatype IF teapot (small) THEN add 1 teabag USING teatype 500: !Serve Tea POUR tea INTO cup UNTIL cup/s ( is/are full) IF (need more tea) THEN GOTO 100: ELSE (enough tea) STOP (making tea)
 
 Pseudo Code for the Computer The ALL-CAPS are the part of Code & Rest are Variables
 
 100: !Fill Kettle with water IF kettle (empty) THEN (Fill kettle with water) IF kettle (filled) THEN GOTO 200 :!Boil water
 
 Instructions to Human Fill Kettle with water Boil water Get teapot Fill teapot with bags Fill with water Get cups Wait until ready Pour out Add Milk Serve Tea
 
 Warmup - Programming
 
 BASIC (Beginner's All-Purpose Symbolic Instruction Code) Programming created in 1964 for a PC Let’s open http://www.quitebasic.com/
 
 NOW Click RUN Button See What happens Now Let’s write a simple program 100 150 200 300 400 500 600 700
 
 CLS let a=25 let b=3 let c=a+b let d=(a+b) * (a-b) print c print d print "That was cool"
 
 Where to get Python from ?
 
 https://www.python.org/downloads/ Download for the Interpreter Version 3.7
 
 Before you start - Some Geeky Stuff ! Get Command Prompt (DOS Box) Windows>Run : & cmd
 
 8
 
 https://www.python.org/downloads/ Download for the Interpreter Version 3.7 OR Web Based Python IDE – repl.it
 
 Keystroke Result CTRL+C CTRL+X CTRL+V CTRL+Z CTRL+SHIFT+Z F5 SLIDE
 
 13
 
 Copy selected text Cut selected text Paste Undo the last keystrokes Redo the last keystrokes Run the module/ Code
 
 Python - IDLE
 
 Python Interactive IDE (Integrated Development Environment)
 
 Microsoft Visual Studio 2017 Free)
 
 OR
 
 Web Based Python IDE – repl.it (Totally
 
 Let’s Start – IDLE-Repl.it Browse to https://repl.it/repls Create an Account (using your email) & We are ready to go
 
 lets start - Hello World ! – First Program NOW LETS TYPE IN THE CONSOLE & HIT ENTER print("Hello world!") CORRECT Observe Spaces print ("Hello world!") Observe Capital/Small cases print( "Hello world!") Observe Parentheses
 
 8 8 8
 
 WATCH FOR SYNTAX print "Hello world!" Print("Hello world!") print(Hello world!)
 
 ✓ ✓ ✓
 
   
 
 NOW LETS INTRODUCE A VARIABLE
 
 msg = "Hello world!" print(msg)
 
 8
 
 SLIDE
 
 16
 
 8
 
 Observe
 
 WRONG Observe Spaces Observe Capital/Small cases Observe Parentheses Observe
 
 Welcome Python ! – Second Program print("Hello, Welcome Python!") num1=20 num2=30 sum1 = num1+num2 print (sum1) print("___________") num3, num4 = 20.5, 30.5 print(num3+num4)
 
 # print statement must use brackets
 
 what is a - VARIABLES! Variables store single value
 
 VARIABLES : are PlaceHolders to store data a,b,c = 1,2.65,"John" Raining = True # True is a Reserved Word print(a,b,c) print ("var a is of type ", type(a)) print ("var b is of type ", type(b)) print ("var c is of type ", type(b)) print ("var Raining is of type ", type(Raining)) firstNumber = 10 secondNumber = 20 print (firstNumber + secondNumber) Angry=bool(0) # To Define Something is True/False Hungry=bool(1) print(Angry, Hungry) print ('First line..'), print ('Continuation on the same line')
 
 EXAMPLES A=5 B=6 C=A*B print(C) print('3+4') print(3+4) print('The value of 3+4 is', 3+4) print('A', 1, 'XYZ', 2)
 
 x ="Python is " y ="awesome" z = x + y print(z) x = 5 y = "John" print(x + y)
 
 what are - OPERATORS x, y = 15, 4 print('x + y =',x+y) print('x - y =',x-y) print('x * y =',x*y) print('x / y =',x/y) print('x // y =',x//y) print('x ** y =',x**y) print('~~~~~~~~~~~~~~~~') a = 5*3+4-9 b = 27/3-3 c = 1+3**2 d = a%b e = c-d print(a,'|', b,'|',c,'|',d,'|',e) check1 = c < d print (check1) x,y,z = 10,20,30 print(x**2+2*x*+z**2) SLIDE
 
 19
 
 Operator
 
 Description
 
 Example
 
 + Addition
 
 Adds values on either side of the operator.
 
 a + b = 30
 
 - Subtraction
 
 Subtracts right hand operand from left hand operand.
 
 a – b = -10
 
 * Multiplies values on either side of Multiplication the operator
 
 a * b = 200
 
 / Division
 
 Divides left hand operand by right hand operand
 
 b/a=2
 
 % Modulus
 
 Divides left hand operand by right hand operand and returns remainder
 
 b%a=0
 
 ** Exponent
 
 Performs exponential (power) calculation on operators
 
 a**b =10 to the power 20
 
 //
 
 Floor Division - The division of operands where the result is the quotient in which the digits after the decimal point are removed. But if one of the operands is negative, the result is floored, i.e., rounded away from zero (towards negative infinity) −
 
 9//2 = 4 and 9.0//2.0 = 4.0, -11//3 = -4, -11.0//3 = -4.0
 
 what is a - FUNCTION https://docs.python.org/3/library/functions.html Built-in Functions abs()
 
 delattr()
 
 hash()
 
 memoryview( )
 
 set()
 
 all()
 
 dict()
 
 help()
 
 min()
 
 setattr()
 
 any()
 
 dir()
 
 hex()
 
 next()
 
 slice()
 
 ascii()
 
 divmod()
 
 id()
 
 object()
 
 sorted()
 
 bin()
 
 enumerate()
 
 input()
 
 oct()
 
 staticmethod( )
 
 bool()
 
 eval()
 
 int()
 
 open()
 
 str()
 
 breakpoint()
 
 exec()
 
 isinstance( ord() )
 
 sum()
 
 bytearray()
 
 filter()
 
 issubclass( pow() )
 
 super()
 
 bytes()
 
 float()
 
 iter()
 
 print()
 
 tuple()
 
 callable()
 
 format()
 
 len()
 
 property()
 
 type()
 
 chr()
 
 frozenset()
 
 list()
 
 range()
 
 vars()
 
 classmethod( )SLIDE 20
 
 getattr()
 
 locals()
 
 repr()
 
 zip()
 
 globals()
 
 map()
 
 reversed()
 
 __import__()
 
 compile()
 
 Functions are named blocks of code, designed to do one specific job. Information passed to a function is called an argument, & information received by a function is called a parameter.
 
 some- BUILT-IN FUNCTIONS(Some ) Built-in Functions name = input('Enter your name: ') print('Hello,', name, '-Welcome to Python Class') print('Type of Variable Name', type(name)) temp = eval(input('Enter temp in Celsius: ')) print(temp,'degree Celcius is', 9/5*temp+32,'degree Fahrenheit') print('____________________________________________') bill = 23.60 tip = 23.60*.15 print('(15% Tip) Bill amount=', bill,'+ Tip=', tip) print('Total Amount is ' '€{:.3f}'.format(bill)) print('____________________________________________') print('Cost: ${:.2f}, Total: ${:.4f}'.format(tip, bill+tip)) a = 12.1691 * 0.176 print('2 Decimals {:.2f}'.format(a)) print('3 Decimals {:.3f}'.format(a)) print('7 Decimals {:.7f}'.format(a)) print('{:3d}'.format(2)) print('{:3d}'.format(25)) print('{:3d}'.format(138)) SLIDE
 
 21
 
 input() dict() eval() len() format() type() print()
 
 BUILT-IN FUNCTIONS…contd EXAMPLES of - MIN() & MAX() print("Maximum of 4,12,43.3,19,225 and 100 is : ",end="") print (max( 4,12,43.3,19,225,100 ) ) print ('Minimim of 4.03 & 3.04 is :', min( 4.03,3.04) ) print("The word occuring 1st in dict. among given is : ",end="") print (min( "geeks", "chandra", "algorithm", "programming" ) ) print('____________________________________________________________')
 
 SLIDE
 
 22
 
 STRINGS (…) Strings store multiple Words String1 = 'Welcome to the Geeks World.' String2 = "I'm going to be a Python Geek soon" print(String1, String2) # Printing both strings print(String1[8:14]) # Printing chars between 8th & 14th print(String2[0], String2[-1]) # Printing first & last characters print(String1[3:-2]) # Printing characters between 3rd and 2nd last char
 
 LISTS […] Lists store multiple values List1 = [] # Creating a blank List print(List1) MyList = ["Apple", "Dell", "HP"] print("List containing multiple values: ") print(MyList[0], (MyList[2])) List = [['Apple', 'iPod'] , ['Acer']] print("\nMulti-Dimensional List: ") print(List) List = [1, 2, 4, 4, 3, 3, 3, 6, 5] # Creating a List with duplicate Numbers print("\nList with the use of Numbers: ") print(List) List = [1, 2, 'Compaq', 4, 'For', 6, 'Banana'] #Creating a List with mixed type of values print("\nList with the use of Mixed Values: ") print(List)
 
 TUPLES (...) Tuples store multiple values & are indexed Tuple0 = ('Geeks', 'For') print("\nTuple with the use of String: ") print(Tuple0) Tuple1 = (0, 1, 2, 3) # Nested Tuples Tuple2 = ('python', 'geek') Tuple3 = (Tuple1, Tuple2) print("\nTuple with nested tuples: ") print(Tuple3)
 
 Tuple is a collection of Python objects much like a list. The sequence of values stored in a tuple can be of any type, and they are indexed by integers. The important difference between a list and a tuple is that tuples are immutable
 
 SETS (...) Tuples store multiple values & are indexed
 
 Set is an unordered collection of data type that is iterable, mutable and has no duplicate elements
 
 set1 = set() #Intial blank Set print(set1) set1 = set("PythonForDesigners") # Creating a Set with a String print("\nSet with the use of String: ") print(set1) String = 'PythonForDesigners' # Creating a Set with a Constructor set1 = set(String) print("\nSet with the use of an Object: " ) print(set1) set1 = set(["Python", "For", "Designers"]) # Creating a Set with a List print("\nSet with the use of List: ") print(set1) set1 = set([1, 2, 4, 4, 3, 3, 3, 6, 5]) print("\nSet with the use of Numbers: ") print(set1) set1 = set([1, 2, ‘Python', 4, 'For', 6, 'Designers']) # Creating a Set with mix print("\nSet with the use of Mixed Values") print((set1))
 
 DICTIONARY {…} Dictionary maps unique keys to values. Dict = {} print("Empty Dictionary: ") print(Dict) Dict = {1: 'Python', 2: 'For', 3: 'Designers'} # Creating a Dictionary with Integer Keys print("\nDictionary with the use of Integer Keys: ") print(Dict)
 
 Dict = {'Name': 'Python', 1: [1, 2, 3, 4]} # Creating a Dictionary with Mixed keys print("\nDictionary with the use of Mixed Keys: ") print(Dict) Dict = dict({1: 'Python', 2: 'For', 3:'Designers'}) # Creating with dict() method print("\nDictionary with the use of dict(): ") print(Dict) # Creating a Nested Dictionary SJ_Arch = {1: {'A' : 'Studio1', 'B' : 'Studio2', 'C' : 'Studio3'}, 2: {'D' : 'Township1', 'E' : 'Township2', 'F' : 'Township3'}} print("\nNested Dictionary: ") print(SJ_Arch)
 
 ARRAYS […] are LISTs Array are similar to Lists, which can hold more than one value at a time cars = ["Ford", "Volvo", "BMW"] for x in cars: print(x) print('\n..........................') cars[0] = "Toyota" print(cars) cars.append("Mecedes") cars.append("Mazda") print('\n', (cars)) cars.remove("BMW") print('\n', (cars)) cars.count(3) print('\n', (cars))
 
 Method
 
 Description
 
 append()
 
 Adds an element at the end of the list
 
 clear()
 
 Removes all the elements from the list
 
 copy()
 
 Returns a copy of the list
 
 count()
 
 Returns the number of elements with the specified value
 
 extend()
 
 Add the elements of a list (or any iterable), to the end of the current list
 
 index()
 
 Returns the index of the first element with the specified value
 
 insert()
 
 Adds an element at the specified position
 
 pop()
 
 Removes the element at the specified position
 
 remove()
 
 Removes the first item with the specified value
 
 reverse()
 
 Reverses the order of the list
 
 sort()
 
 Sorts the list
 
 ARRAYS vs Lists Array are similar to Lists, except that it arrays contain same type of data MyList = [1, 2, 'Compaq', 4, 'For', 6, 'Banana'] print(MyList) import array as arr YrArray = arr.array(93.5, 5.6, 9.9, 2.1) print('\n',YrArray) MyArray = arr.array('d', [1, 3.5, "Hello"]) import array as arr a = arr.array('d', [1.1, 3.5, 4.5]) print(a)
 
 USER-DEFINED FUNCTIONS( ) def sum_two_numbers(a, b): return a + b def my_function(): # Define our 3 functions print("Hello From My Function!")
 
 def my_function_with_args(username, greeting): print("Hello, %s , from this city, I wish you %s"%(username, greeting)) my_function() # print(a simple greeting) my_function_with_args("Johnson", "good day") # print with Arguments print(sum_two_numbers(1,2))
 
 USER-DEFINED FUNCTIONS( ) def greet(name): print ('Hi',name,'Good morning!') greet('Patrick') def area(r): a = (22.0/7.0)*r*r return a L=(area(21)) def add(x,y): sum = x + y return sum M=add(25,34) print(L,'\n',M)
 
 def fruit_basket(): return "Mango", "Banana", "Apple", "Grapes", "Durian"
 
 def essay(quality): # concatenate to each line in essay !" return "%s tastes nice if grown organically!" % quality
 
 def write_essay(): Fruits = fruit_basket() for quality in Fruits: print(essay(quality)) write_essay()
 
 USER-DEFINED FUNCTIONS( ) def sumProblem(x, y): sum = x + y sentence = 'The sum of {} and {} is {}.'.format(x, y, sum) print(('\n'), sentence) def main(): a = int(input("Enter an integer: ")) b = int(input("Enter another integer: ")) sumProblem(a, b) sumProblem(1234567890123, 535790269358) print('\n') main()
 
 x= sorted([5, 2, 3, 1, 4]) print(x) list1=[1,10,3,23,333,0,65,99] list1.sort() print (list1) list2 = ["Bans","Trop","Indi","Firr","Bor","Borr"] list2.sort() print(list2) list3 = ["1","10","3","22","23","4","2"] list3.sort(key=int) print(list3)
 
 IF, CONDITIONAL STATEMENTs #4 Days in a month days = int(input('Enter number of days: ')) if days == 28 or days == 29: print('Feb') elif days == 30: print('Apr, Jun, Sep, Nov') elif days == 31: print('Jan, Mar, May, Jul, Aug, Oct, Dec') else: print('Error - Key in 28,29,39 or 31')
 
 l=[0,1,2,3,4,5,6,7,8,9] lo=0 for i in l: lo=lo+100 if not l[i]>> math import math x= math.pi print(x) from math import pi r = float(input ("radius : ")) Circ= 2*pi*r print("Circumference f the Circle is :" , r)
 
 import math def distance_bet_two_points(x1,x2,y1,y2): return math.sqrt((x1-x2)**2 + (y1-y2)**2) res = distance_bet_two_points(1,-4,0,-1) print(res)
 
 acos acosh asin asinh atan atan2 atanh ceil copysign cos cosh degrees e erf erfc exp expm1 fabs factorial floor fmod
 
 frexp fsum gamma hypot isinf isnan ldexp lgamma log log10 log1p modf pi pow radians sin sinh sqrt tan tanh trunc
 
 PACKAGES, MODEULES, >>> date, time import time import datetime print ("Time in seconds since the epoch: %s" %time.time()) print ("Current date and time: " , datetime.datetime.now()) print ("Or like this: " ,datetime.datetime.now().strftime("%y/%m/%d %H:%M")) print print print print print print print
 
 ("Current year: ", datetime.date.today().strftime("%Y")) ("Month of year: ", datetime.date.today().strftime("%B")) ("Week number of the year: ", datetime.date.today().strftime("%W")) ("Weekday of the week: ", datetime.date.today().strftime("%w")) ("Day of year: ", datetime.date.today().strftime("%j")) ("Day of the month : ", datetime.date.today().strftime("%d")) ("Day of week: ", datetime.date.today().strftime("%A"))
 
 DOB = datetime.date(1943,3, 13) #year, month, day print(DOB.strftime("%A"))
 
 PACKAGES, MODEULES, >>> calender import pandas as pd # Create some variables trials = [1, 2, 3, 4, 5, 6] subj_id = [1]*6 group = ['Control']*6 condition = ['Affect']*3 + ['Neutral']*3 # Create a dictionairy data = {'Condition':condition, 'Subject_ID':subj_id, 'Trial':trials, 'Group':group} # Create the dataframe df = pd.DataFrame(data) df.head() print(df)
 
 PACKAGES, MODEULES, >>> pandas Excel import pandas as pd I/E xlsx_source = 'd:\\360products.xlsx' col_names = ['Col' + str(i) for i in range (1, 5)] # Reading the excel file to a dataframe. # Note, there's only one sheet in the example file df = pd.read_excel(xlsx_source, sheet_name='ByAllProducts', skiprows=[0]) df.head() print(df)
 
 PACKAGES >>> beautifulsoup import bs4 import requests res=requests.get('http://www.boa.gov.sg/register.html') # type(res) #What is this object # print(res.text) #What is content of this object
 
 soup = bs4.BeautifulSoup(res.text, 'lxml' ) type(soup) soup.title soup.title.name soup.title.string soup.title.parent.name
 
 BEAUTIFULSOUP import bs4 import requests res=requests.get('http://www.boa.gov.sg/register.html') # type(res) #What is this object # print(res.text) #What is content of this object
 
 soup = bs4.BeautifulSoup(res.text, 'lxml' ) type(soup) soup.title soup.title.name soup.title.string soup.title.parent.name
 
 BEAUTIFULSOUP import requests from bs4 import BeautifulSoup page = requests.get("https://www.gebiz.gov.sg/ptn/opportunity/BOListing.xhtml?origin=search") # print(page.content) soup = BeautifulSoup(page.content, 'html.parser') # print(soup) # print(soup.prettify()) tender_no= soup.findAll ('div', {'class' : 'formSectionHeader6_TEXT'}) #print(tender_no) #_____________________________________________________________________________________________ tender_ttl= soup.find_all('a', {'class' : 'commandLink_TITLE-BLUE'}) #print(tender_ttl) tno=[] tttl=[] for x in range(len(tender_no)): print (tender_no[x].get_text()) tno.append(tender_no[x].get_text()) #print(tender_ttl) for x in range(len(tender_ttl)): print (tender_ttl[x].get_text()) tttl.append(tender_ttl[x].get_text())
 
 SMALL APP- Find BMI bmi = weight/(height*height) print('\t\t\t BMI Calculator') print('\t\t\t this is a BMI Calculator') i= input('\nWhat units you want metric or imperial (m or i): ') while i == 'm': height = input(‘Enter your height input meters(decimals): ') if height == 'x' : break else : height = float(height) weight = float(input('Please enter your weight input kg: ')) bmi = weight/(height*height) if bmi 18.5 and bmi < 25: print('Your BMI is', bmi,'which means you are normal.') elif bmi > 25 and bmi < 30: print('your BMI is', bmi,'overweight.') elif bmi > 30: print('Your BMI is', bmi,'which means you are obese.') else: print('There is an error with your input') print('Please check you have entered whole numbers\n' 'and decimals were asked.')
 
 while i == 'i': height = input('\nEnter height in inches(whole number) x to quit: ') if height == 'x' : break else : height = int(height) weight = int(input(‘Enter your weight input pounds(whole number): ')) bmi = (weight*703)/(height*height) if bmi 18.5 and bmi < 25: print('Your BMI is', bmi,'which means you are normal.') elif bmi > 25 and bmi < 30: print('Your BMI is', bmi,'which means you are overweight') elif bmi > 30: print('Your BMI is', bmi,'which means you are obese.') else: print('There is an error with your input') print('Please check you have entered whole numbers\n' 'and decimals were asked.') input('\n\nPlease press enter to exit.')
 
 HTML HTML is the standard language for creating any Web pages
 
 HTML : Hyper Text Markup Language HTML describes the structure of Web pages using markups HTML elements(TAGS) are the building blocks of HTML pages Browsers do not display the HTML tags, but use them to render the content of the page 
 
 
 
 Page Title
 
 My First Heading 
My first paragraph.
 element defines a paragraph
 
 HTML & TAGS HTML is the standard language for creating any Web pages 
 
 
 
 Page Title
 
 My First Heading 
My first paragraph.