GENERAL PROGRAM PIECESWhile – forward a bow. executes the boot iteratively as extended as the provided judicious loudness is true(ie, not zero)break – breaks a bow pronto – jumpts to the aimless of the on or whileurllib, ftplib – module on using URLs or FTP accessrandom – module on generating indefinite numbers or making indefinite choicesos, sys – module on manipulating operating organized for the most part or Python systemstr – converts numbers (or other subjects) to their strand representationsfloat – converts a issue or strand to its floating essence commensurate representationSTRING FUNCTIONS surprisingly, FUNCTIONS AND PIECESstring[n],string[n:m] – returns the goodness in the strand at angle n([n]), or the substring from n to m -1. muse on that these start at favourable mention 0startwith – returns faithful if the strand starts with the input strand. endswith – returns faithful if the strand ends witht he input strand. FUNCTION CREATION#we completed functions with def. value – returns the favourable mention if the input strand is bring about in the string;-1 otherwiseupper, richness down – convers the for the most part strand to the specified caseisalpha, is digit – returns faithful if the for the most part strand is alphabetic or numeric digits respectivelyreplace – takes two input substrings – replaces all instances of teh maiden with the B in the prearranged stringsplit – bursts a strand into a bullshit heap of substrings using the input strand as the delimiterLIST FUNCTIONS AND PIECESappend – appends the input to the aimless of the listremove – removes the input from the listsort – sorts the listreverse – reverses the listcount – counts the issue of times the input appears in the listmax, min – gives a bullshit heap of numbers as input, returns the limit or lowest (respectively) value in the bullshit heap. def x(a,b) surprisingly: defines a function named X that takes two input values which choice be inexorable to variables a and b.
the boot of the function comes after the def and is indented. LOOPS AND CONDITIONALS#we forward most of our loops using on, which takes an favourable mention fluctuating and a bullshit heap. teh function can redress values using the redress account. the boot of the bow is executed conclusively on each extend of the bullshit heap. >>>for p in [1,2,3]:…..print pThe bullshit heap in a on is frequently generated using a extend function. with anyone input, the extend is from zero to the input.
range can filch 1/2/3 inputs. with two, the extend starts at the maiden input and stops sooner than the B. with tree, the extend starts at the maiden, takes steps of the third, and ends sooner than the B. if it is faithful, the if’s bedim underrate completed is executed.
The bow while takes a judicious loudness and exevutes its bedim underrate completed as extended as the judicious loudness is true>>>x=1>>>while x < 5:…..print x…..x=x+1A balk pronto ends the au fait loopAn if takes a judicious loudness and evaluates it. if it is forged, the else: clause is executed, if anyone exists.