Loading [MathJax]/extensions/mml2jax.js
Skip to main content
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
Geosciences LibreTexts

Search

  • Filter Results
  • Location
  • Classification
    • Article type
    • Cover Page
    • License
    • Show TOC
    • Transcluded
    • Author
    • OER program or Publisher
    • Autonumber Section Headings
    • License Version
  • Include attachments
Searching in
About 92 results
  • https://geo.libretexts.org/Courses/Texas_AM/ATMO_321%3A_python_for_atmospheric_sciences/07%3A_Lists/7.15%3A_Debugging
    Since we are breaking this line into words, we could dispense with the use of startswith and simply look at the first word of the line to determine if we are interested in the line at all. The best pl...Since we are breaking this line into words, we could dispense with the use of startswith and simply look at the first word of the line to determine if we are interested in the line at all. The best place to add the print statement is right before the line where the program failed and print out the data that seems to be causing the failure.
  • https://geo.libretexts.org/Courses/Texas_AM/ATMO_321%3A_python_for_atmospheric_sciences/02%3A_Variables_Expressions_and_Statements/2.09%3A_Asking_the_user_for_input
    Sometimes we would like to take the value for a variable from the user via their keyboard. Python provides a built-in function called input that gets input from the keyboard. When this function is cal...Sometimes we would like to take the value for a variable from the user via their keyboard. Python provides a built-in function called input that gets input from the keyboard. When this function is called, the program stops and waits for the user to type something. When the user presses Return or Enter, the program resumes and input returns what the user typed as a string.
  • https://geo.libretexts.org/Courses/Texas_AM/ATMO_321%3A_python_for_atmospheric_sciences/02%3A_Variables_Expressions_and_Statements/2.10%3A_Comments
    As programs get bigger and more complicated, they get more difficult to read. Formal languages are dense, and it is often difficult to look at a piece of code and figure out what it is doing, or why. ...As programs get bigger and more complicated, they get more difficult to read. Formal languages are dense, and it is often difficult to look at a piece of code and figure out what it is doing, or why. For this reason, it is a good idea to add notes to your programs to explain in natural language what the program is doing. These notes are called comments, and in Python they start with the # symbol.
  • https://geo.libretexts.org/Courses/Texas_AM/ATMO_321%3A_python_for_atmospheric_sciences/02%3A_Variables_Expressions_and_Statements/2.04%3A_Statements
    A statement is a unit of code that the Python interpreter can execute. We have seen two kinds of statements: print being an expression statement and assignment.
  • https://geo.libretexts.org/Courses/Texas_AM/ATMO_321%3A_python_for_atmospheric_sciences/03%3A_Conditional_Execution/3.E%3A_Conditional_Execution_(Exercises)
    Exercise 1: Rewrite your pay computation to give the employee 1.5 times the hourly rate for hours worked above 40 hours. Exercise 2: Rewrite your pay program using try and except so that your program ...Exercise 1: Rewrite your pay computation to give the employee 1.5 times the hourly rate for hours worked above 40 hours. Exercise 2: Rewrite your pay program using try and except so that your program handles non-numeric input gracefully by printing a message and exiting the program. Enter Hours: 20 Enter Rate: nine Error, please enter numeric input Exercise 3: Write a program to prompt for a score between 0.0 and 1.0. If the score is between 0.0 and 1.0, print a grade using the following table:
  • https://geo.libretexts.org/Courses/Texas_AM/ATMO_321%3A_python_for_atmospheric_sciences/07%3A_Lists/7.E%3A_Lists_(Exercises)
    Exercise 6: Rewrite the program that prompts the user for a list of numbers and prints out the maximum and minimum of the numbers at the end when the user enters "done". Write the program to store the...Exercise 6: Rewrite the program that prompts the user for a list of numbers and prints out the maximum and minimum of the numbers at the end when the user enters "done". Write the program to store the numbers the user enters in a list and use the max() and min() functions to compute the maximum and minimum numbers after the loop completes.
  • https://geo.libretexts.org/Courses/Texas_AM/ATMO_321%3A_python_for_atmospheric_sciences/06%3A_Strings/6.04%3A_String_Slices
    The operator returns the part of the string from the "n-eth" character to the "m-eth" character, including the first but excluding the last. If you omit the first index (before the colon), the slice s...The operator returns the part of the string from the "n-eth" character to the "m-eth" character, including the first but excluding the last. If you omit the first index (before the colon), the slice starts at the beginning of the string. If you omit the second index, the slice goes to the end of the string: If the first index is greater than or equal to the second the result is an empty string, represented by two quotation marks:
  • https://geo.libretexts.org/Courses/Texas_AM/ATMO_321%3A_python_for_atmospheric_sciences/04%3A_Functions/4.03%3A_Type_Conversion_Functions
    Python also provides built-in functions that convert values from one type to another. The int function takes any value and converts it to an integer, if it can, or complains otherwise.
  • https://geo.libretexts.org/Courses/Texas_AM/ATMO_321%3A_python_for_atmospheric_sciences/07%3A_Lists/7.05%3A_List_Slices
    The slice operator also works on lists.
  • https://geo.libretexts.org/Courses/Texas_AM/ATMO_321%3A_python_for_atmospheric_sciences/09%3A_Dictionaries/9.02%3A_Dictionary_as_a_Set_of_Counters
    An implementation is a way of performing a computation; some implementations are better than others. For example, an advantage of the dictionary implementation is that we don't have to know ahead of t...An implementation is a way of performing a computation; some implementations are better than others. For example, an advantage of the dictionary implementation is that we don't have to know ahead of time which letters appear in the string and we only have to make room for the letters that do appear.
  • https://geo.libretexts.org/Courses/Texas_AM/ATMO_321%3A_python_for_atmospheric_sciences/06%3A_Strings/6.07%3A_String_Comparison
    if word < 'banana': print('Your word,' + word + ', comes before banana.') elif word > 'banana': print('Your word,' + word + ', comes after banana.') else: print('All right, bananas.') All the uppercas...if word < 'banana': print('Your word,' + word + ', comes before banana.') elif word > 'banana': print('Your word,' + word + ', comes after banana.') else: print('All right, bananas.') All the uppercase letters come before all the lowercase letters, so: A common way to address this problem is to convert strings to a standard format, such as all lowercase, before performing the comparison. Keep that in mind in case you have to defend yourself against a man armed with a Pineapple.

Support Center

How can we help?