Conditional Programming In Python
Applications are becoming more and more sophisticated as languages such as Python open the doors to the world of programming for people who have the creative vision but always felt actually writing code was beyond their grasp.
A large part of any programs success is based on how well it can react to the events which it has been programmed to understand and listen for.
A good example of an event would be when the user clicks a button on the applications window. What happens when that button is clicked?
Well, the first thing that happens is the operating system sends out a message to let any listening software know that the button was clicked. Next, your application needs to do something in response to that event.
But what should it do?
Well, that is down to you. As your skills grow you will realize that your software needs to be able to make decisions on its own.
Just like the button click scenario, if your application hasn’t been programmed to perform a specific action then it won’t. It is down to you, the programmer, to give the application a specific set of instructions which should be followed if a button is clicked.
Take a look at the following code and then I will explain what it all means:
buttonClick = “yes” if buttonClick == “yes”: print “The button was clicked” else: print “The button was not clicked”
The above code introduces the if-else conditional statements. I will explain what the code its self does first before going into more detail about the statements.
On line one we create a variable called buttonClick and assign it the value of “yes”.
Then starting on line two we enter an if-else conditional block which essentially checks if our buttonClick variable holds the string “yes”, and if it does it will print out the string on line 3.
In this particular case it is obvious that our variable does hold the correct value so after our success message has been printed to the screen the program will skip the remaining else statement.
If we changed the value of our variable to ‘no’ then the else statement would be executed and our failure message would be displayed.
If you try out the above code you will begin to understand just how import conditional constructs, such as the if-else clause, can be incredibly useful for checking if some event, or in the case of our code, if a variable holds a particular value.
Realistically you can’t create a good piece of software, not even something as simple as a calculator, without the use of conditional statements. They arm you with a means to give your code a way to react and respond in a more sophisticated and intelligent way.
When we take a look at loops in a future tutorial you will learn how you can use these statements to check multiple values for the correct one before the application will continue executing the rest of the code.
other blog entries
Course Directory [training on all levels]
- .NET Classes
- Agile/Scrum Classes
- Ajax Classes
- Android and iPhone Programming Classes
- Blaze Advisor Classes
- C Programming Classes
- C# Programming Classes
- C++ Programming Classes
- Cisco Classes
- Cloud Classes
- CompTIA Classes
- Crystal Reports Classes
- Design Patterns Classes
- DevOps Classes
- Foundations of Web Design & Web Authoring Classes
- Git, Jira, Wicket, Gradle, Tableau Classes
- IBM Classes
- Java Programming Classes
- JBoss Administration Classes
- JUnit, TDD, CPTC, Web Penetration Classes
- Linux Unix Classes
- Machine Learning Classes
- Microsoft Classes
- Microsoft Development Classes
- Microsoft SQL Server Classes
- Microsoft Team Foundation Server Classes
- Microsoft Windows Server Classes
- Oracle, MySQL, Cassandra, Hadoop Database Classes
- Perl Programming Classes
- Python Programming Classes
- Ruby Programming Classes
- Security Classes
- SharePoint Classes
- SOA Classes
- Tcl, Awk, Bash, Shell Classes
- UML Classes
- VMWare Classes
- Web Development Classes
- Web Services Classes
- Weblogic Administration Classes
- XML Classes
did you know? HSG is one of the foremost training companies in the United States
Our courses focus on two areas: the most current and critical object-oriented and component based tools, technologies and languages; and the fundamentals of effective development methodology. Our programs are designed to deliver technology essentials while improving development staff productivity.
An experienced trainer and faculty member will identify the client's individual training requirements, then adapt and tailor the course appropriately. Our custom training solutions reduce time, risk and cost while keeping development teams motivated. The Hartmann Software Group's faculty consists of veteran software engineers, some of whom currently teach at several Colorado Universities. Our faculty's wealth of knowledge combined with their continued real world consulting experience enables us to produce more effective training programs to ensure our clients receive the highest quality and most relevant instruction available. Instruction is available at client locations or at various training facilities located in the metropolitan Denver area.
Upcoming Classes
consulting services we do what we know ... write software
The coaching program integrates our course instruction with hands on software development practices. By employing XP (Extreme Programming) techniques, we teach students as follows:
Configure and integrate the needed development tools
MOntitor each students progress and offer feedback, perspective and alternatives when needed.
Establish an Action plan to yield a set of deliverables in order to guarantee productive learning.
Establish an Commit to a deliverable time line.
Hold each student accountable to a standard that is comparable to that of an engineer/project manager with at least one year's experience in the field.
These coaching cycles typically last 2-4 weeks in duration.
Business Rule isolation and integration for large scale systems using Blaze Advisor
Develop Java, .NET, Perl, Python, TCL and C++ related technologies for Web, Telephony, Transactional i.e. financial and a variety of other considerations.
Windows and Unix/Linux System Administration.
Application Server Administration, in particular, Weblogic, Oracle and JBoss.
Desperate application communication by way of Web Services (SOAP & Restful), RMI, EJBs, Sockets, HTTP, FTP and a number of other protocols.
Graphics Rich application development work i.e. fat clients and/or Web Clients to include graphic design
Performance improvement through code rewrites, code interpreter enhancements, inline and native code compilations and system alterations.
Mentoring of IT and Business Teams for quick and guaranteed expertise transfer.
Architect both small and large software development systems to include: Data Dictionaries, UML Diagrams, Software & Systems Selections and more