Beginner Python: Your Practical Guide to Managing Data with Basic Python by Matthew Dewey

Beginner Python: Your Practical Guide to Managing Data with Basic Python by Matthew Dewey

Author:Matthew Dewey [Dewey, Matthew]
Language: eng
Format: azw3
Published: 2020-05-03T16:00:00+00:00


With those basic conditions you can create many useful if statements. Comparing data is exactly what you need to do to ensure you manage and process it correctly.

For example, let’s say a user inputs their age and you need to check if they are 30 years old or older:

age_int = int ( input ( "Enter your age: " ))

if age_int >= 30 :

​ print ( "You are 30 or older" )

It’s a simple, but important program that is used to check the age of clients in many services.

(NOTE: You will see that I don’t encapsulate the condition in a set of brackets. Doing so is not necessary as you will find most Python programmers don’t. There is no issue in encapsulating your conditions if you choose to do so)

To take this further, you can even compare strings using these functions. Of course, it has to be case sensitive, as if a letter is in a different case, although it being the same letter, it will be read as different.

name_str = "John"

if name_str == "John" :

​ print ( "Ah, Jonathan, nice to meet you!" )



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.