<jupyter_start><jupyter_text>Lab 1: Python basics Structure/Objectives: 1. Basic operations (1 point)**1.1.** (0.25 point) Create a variable called `var1` that equals the integer 10. Create another variable called `var2` that equals the float 2.5. Multiply `var1` by `var2` and call the result `var3`. **1.2.** (0.25 point) Check the type of `var3` and describe why `var3` is this type of numerical value using a comment (i.e., ` comments`) or `print()` function. **1.3.** (0.25 point) Define two strings: `string1` contains the word "ink" and `string2` contains the word "jet". Combine the two words together and call the resultant variable `printer`.**1.4.** (0.25 point) Split the string `printer` by the letter "k" and save the resultant list in a variable named `reslist`. 2. Make a list (1 point)**2.1.** (0.5 point) Create a variable called `alist` that contains, in order, the string 'dog', the boolean True, and the number 34. Write your answer in the following cell.**2.2.** (0.5 point) Change the last entry of the list to equal the list `[2,5,9]`. 3. Make a dictionary (1 point)**3.1.** (0.5 point) Make a dictionary that contains the capital cities of a given state. Instead of all 50 states, just include New York, Illinois, Texas, and California. **3.2.** (0.5 point) Keep the keys of the dictionary as the name of the four states, but change the values of the dictionary from strings to lists. For the entries of the lists, the first value will still be the capitals of each state and the second value will be the largest city by population of each state.  4. Test for vowels (1 point)**4.1.** (0.5 point) Write a function that takes a character (i.e. a string of length 1) and returns True if it is a vowel, False otherwise.**4.2.** (0.5 point) Using a list comprehension, capitalize only the vowels and keep others (i.e., consonant and space) as lower case in the string `This is a random sentence`, then save the result as `capitalized_vowels`.  5. Check for palindromes (1 point)**5.1.** (0.5 point) Define a function reverse() that computes the reversal of a string. **5.2.** (0.5 point) Define a function `is_palindrome()` that recognizes palindromes (i.e. words and phrases that look the same written forwards and backwards).  Notes:**Before you submit your lab, make sure everything runs as expected WITHOUT ANY ERROR.** **Make sure you fill in any place that says `YOUR CODE HERE` or `YOUR ANSWER HERE`:**<jupyter_code>FULL_NAME = ""<jupyter_output><empty_output><jupyter_text>1. Basic operations (1 point) **1.1.** (0.25 point) Create a variable called `var1` that equals the integer 10. Create another variable called `var2` that equals the float 2.5. Multiply `var1` by `var2` and call the result `var3`. **1.2.** (0.25 point) Check the type of `var3` and describe why `var3` is this type of numerical value using a comment (i.e., ` comments`) or `print()` function.<jupyter_code># Your code here


# Write up your answer of 1.2. here


# Test the value of each variable
assert(var1 == 10)
assert(var2 == 2.5)
assert(var3 == 25)

print('Success!')<jupyter_output><empty_output><jupyter_text>**1.3.** (0.25 point) Define two strings: `string1` contains the word "ink" and `string2` contains the word "jet". Combine the two words together and call the resultant variable `printer`.**1.4.** (0.25 point) Split the string `printer` by the letter "k" and save the resultant list in a variable named `reslist`.<jupyter_code># Your code here


# test type of variables
assert(isinstance(string1, str))
assert(isinstance(string2, str))
assert(isinstance(printer, str))

assert(printer == 'inkjet')

assert(isinstance(reslist, list))
assert(reslist[0] == 'in')
assert(reslist[1] == 'jet')

print('Success!')<jupyter_output><empty_output><jupyter_text>2. Make a list (1 point)**2.1.** (0.5 point) Create a variable called `alist` that contains, in order, the string 'dog', the boolean True, and the number 34. Write your answer in the following cell.<jupyter_code># Your code here


# This line tests to see if the variable you created, called `alist`, is of type list, and contains the correct element types
assert(isinstance(alist, list))
assert(isinstance(alist[0], str))
assert(isinstance(alist[1], bool))
assert(isinstance(alist[2], int))

# This line tests to make sure the correct elements are contained in the list
assert(alist[0] == 'dog')
assert(alist[1] == True)
assert(alist[2] == 34)

print('Success!')<jupyter_output><empty_output><jupyter_text>**2.2.** (0.5 point) Change the last entry of the list to equal the list `[2,5,9]`.<jupyter_code># Your code here


assert(isinstance(alist[2], list))
assert(alist[2] == [2,5,9])

print('Success!')<jupyter_output><empty_output><jupyter_text>3. Make a dictionary (1 point)**3.1.** (0.5 point) Make a dictionary that contains the capital cities of a given state. Instead of all 50 states, just include New York, Illinois, Texas, and California. The dictionary must be called `major_cities` and should be able to used as follows:```python    major_cities['Texas'] = 'Austin'```<jupyter_code># Your code here


""" Test code for the previous code. This cell should NOT give any errors when it is run."""

# makes sure your code returns a dictionary
assert(isinstance(major_cities, dict))

# checks that the capitals can be accessed correctly
assert(major_cities['Illinois'] == 'Springfield')
assert(major_cities['Texas'] == 'Austin')
assert(major_cities['New York'] == 'Albany')
assert(major_cities['California'] == 'Sacramento')

# if nothing throws an assertion, good job!
print("Success!")<jupyter_output><empty_output><jupyter_text>**3.2.** (0.5 point) Keep the keys of the dictionary as the name of the four states, but change the values of the dictionary from strings to lists. For the entries of the lists, the first value will still be the capitals of each state and the second value will be the largest city by population of each state. For example, ```python   major_cities['Texas'] = ['Austin', 'Houston']```<jupyter_code># Your code here


# check the first value of the dictionary is a list
assert(isinstance(major_cities['Illinois'], list))
assert(isinstance(major_cities['Texas'], list))
assert(isinstance(major_cities['New York'], list))
assert(isinstance(major_cities['California'], list))

# check each list has proper entries ([state capital, largest city])
assert(major_cities['Illinois'][0] == 'Springfield')
assert(major_cities['Illinois'][1] == 'Chicago')
assert(major_cities['Texas'][0] == 'Austin')
assert(major_cities['Texas'][1] == 'Houston')
assert(major_cities['New York'][0] == 'Albany')
assert(major_cities['New York'][1] == 'New York')
assert(major_cities['California'][0] == 'Sacramento')
assert(major_cities['California'][1] == 'Los Angeles' or major_cities['California'][1] == 'LA')

# if nothing throws an assertion, good job!
print("Success!")<jupyter_output><empty_output><jupyter_text>4. Test for vowels (1 point)**4.1.** (0.5 point) Write a function that takes a character (i.e. a string of length 1) and returns True if it is a vowel, False otherwise. For example,```python    >>> isVowel("a")    True    >>> isVowel("C")    False```You can compare the input character with a known list of vowels. Don't forget about case!<jupyter_code>def isVowel(char):
    """Takes a character and returns True if it is a vowel, and False otherwise.
    
    Parameters
    ----------
    char : string
        string of length 1
        
    Returns
    -------
    boolean telling whether char is a vowel or not
    
    """
    # Your code here

    
    
# Test your code here


"""(0.25 point) Test code for the previous code. This cell should NOT give any errors when it is run."""
assert isVowel('a')
assert not isVowel('m')
assert not isVowel(' ')

print("Success!")
"""(0.25 point) Test code for the previous code. This cell should NOT give any errors when it is run."""
assert isVowel('U')
assert not isVowel('T')

print("Success!")<jupyter_output><empty_output><jupyter_text>**4.2.** (0.5 point) Using a list comprehension, capitalize only the vowels and keep others (i.e., consonant and space) as lower case in the string `This is a random sentence`, then save the result as `capitalized_vowels`. The following is your expected output. ```python   sentence = 'This is a random sentence'    capitalized_vowels =  use list comrehension here   >>> capitalized_vowels   ['t', 'h', 'I', 's', ' ', 'I', 's', ' ', 'A', ' ', 'r',  'A', 'n', 'd', 'O', 'm', ' ', 's', 'E', 'n',     't', 'E', 'n', 'c', 'E']   ```<jupyter_code>sentence = 'This is a random sentence'
# Your code here

"""(0.5 point) Test code for the previous code. This cell should NOT give any errors when it is run."""
assert capitalized_vowels == ['t', 'h', 'I', 's', ' ', 'I', 's', ' ', 'A', ' ', 'r',  'A', 'n', 'd', 'O', 'm', ' ', 's', 'E', 'n', 't', 'E', 'n', 'c', 'E']

print('Success!')<jupyter_output><empty_output><jupyter_text>5. Check for palindromes (1 point)**5.1.** (0.5 point) Define a function reverse() that computes the reversal of a string. For example, ```python    >>> reverse("I am testing")    "gnitset ma I"    ```<jupyter_code>def reverse(string):
    """Reverse string and then return in.
    
    Parameters
    ----------
    string : str
        
        
    Returns
    -------
    string that is reversed
    """
    # Your code here
    

# Test your code here


"""(0.5 point) Test code for the previous function. This cell should NOT give any errors when it is run."""
assert reverse('I am testing') == 'gnitset ma I'
assert reverse('I am TesTinG') == 'GniTseT ma I'
assert reverse('') == ''

print("Success!")<jupyter_output><empty_output><jupyter_text>**5.2.** (0.5 point) Define a function `is_palindrome()` that recognizes palindromes (i.e. words and phrases that look the same written forwards and backwards). Make sure that case and spaces are ignored in your function; for example,```python    >>> is_palindrome("Never odd or even")    True    >>> is_palindrome("This is a random sentence")    False```<jupyter_code>def is_palindrome(phrase):
    """Returns True for a palindrome and False otherwise.
    
    Parameters
    ----------
    phrase : string
        
        
    Returns
    -------
    Boolean
    """
 
    # Your code here

    
# Test your code here


"""(0.25 point) Test code for the previous function. This cell should NOT give any errors when it is run."""

assert is_palindrome("radar")
assert not is_palindrome("I am testing")

print("These tests pass, more in next cell.")
"""(0.25 point) Test code for the previous function. This cell should NOT give any errors when it is run."""

assert is_palindrome("rad dar")
assert is_palindrome("Never odd or even")

print("Success!")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13636786744857116, 'fraction_numerical': 0.020571534952992646, 'mean_word_length': 4.431749241658241, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '192888', 'license': 'MIT', 'n_tokens_mistral': 3418, 'n_tokens_neox': 3278, 'n_words': 1364, 'path': 'Labs/Lab1/Lab1_Python_Basics.ipynb', 'repo_name': 'jparkgeo/GEOG489', 'size': '10743'}