Python Guide V1.2.11

Value intvalintvarintegercastor

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ol structure • while statement followed by indented lines • while!condition : —loops while condition is True (i.e., not 0) —indented lines are repeated each iteration —to terminate, make condition 0/False/empty • leftToDo,!total6=!100,!0.0! while!leftToDo!:!!#!i.e.,!while!leftToDo!>!0:! !!!!total!!!!+=!1.0!/!count! !!!!leftToDo!R=!1! Input from user • • • • var6=!raw_input("Enter!value:!")! intVal!=!int(var)!#!integer!cast,!or! anyVal!=!eval(var)!#!could!be!dangerous,!or! assert!'@'!in!var,!"%s6not6eRmail6address"!%!var! Operating system functions: ! import!os,!sys!#!operating!system,!system! os.chdir(sys.path[0])6#!change!to!script!file!folder! print!os.listdir('.')!#!file!list!of!current!folder! ©"Terry"Andres"2011,"2012,"2013" abs(x) |x| chr(35)! !'#' dir(x)! !attributes of!x help(x)! !help on using!x len(x)! !length of!x max(2.1,!4,!3)! !4!!!!#!largest!argument min(2.1,!4,!3)! !2.1!!#!smallest!argument ord('#')! !35!!#!ASCII!order range(a,b,c)!see lists round(3.6)! !4...
View Full Document

This document was uploaded on 02/14/2014 for the course COMP 1012 at Manitoba.

Ask a homework question - tutors are online