Back to Course

Intermediate Python

0% Complete
0/0 Steps
Lesson 1 of 33
In Progress

Recap of Key Concepts from Introduction to Python Course

Before diving into the advanced concepts covered in the Intermediate Python course, it is important to have a solid understanding of the key concepts covered in the Introduction to Python course.

Recap of Introduction to Python Course

In the Introduction to Python course, you learned the basics of Python syntax, data types, and operators. You also learned how to create and access lists and dictionaries, as well as how to modify and manipulate them.

You also learned about conditional statements, loops, and functions, and how to use them to control the flow of your programs. You learned about function arguments and return values, as well as how to use recursion to solve problems.

In addition, you learned about modules, packages, and classes, and how to use them to structure and organize your code. You also learned about inheritance and exception handling, and how to use them to handle errors and exceptions in your programs.

Finally, you learned about reading and writing files, as well as how to connect to and manipulate databases using SQL. You also learned about consuming REST APIs and an overview of data science and machine learning.

Conclusion

It is important to have a strong foundation in these concepts before moving on to the advanced topics covered in the Intermediate Python course. If you need to review any of these concepts, be sure to refer back to the Introduction to Python course material before proceeding.

Exercises

To review these concepts, we will go through a series of exercises designed to test your understanding and apply what you have learned.

Write a function that takes a string as input and returns a new string with all vowels removed.

def remove_vowels(s):
    vowels = 'aeiouAEIOU'
    return ''.join([c for c in s if c not in vowels])

print(remove_vowels('Hello World'))  # Hll Wld
print(remove_vowels('Python is fun'))  # Pthn s fn

Write a function that takes a list of integers as input and returns the sum of the even numbers in the list.

def sum_evens(lst):
    return sum([x for x in lst if x % 2 == 0])

print(sum_evens([1, 2, 3, 4, 5, 6]))  # 12
print(sum_evens([7, 8, 9, 10]))  # 18

Write a function that takes a dictionary as input and returns a list of the values sorted in descending order.

def sort_dict_values(d):
    return sorted(d.values(), reverse=True)

print(sort_dict_values({'a': 1, 'b': 3, 'c': 2}))  # [3, 2, 1]
print(sort_dict_values({'d': 4, 'e': 0, 'f': 6}))  # [6, 4, 0]

Write a function that takes a list of strings as input and returns a new list with all the strings capitalized.

def capitalize_list(lst):
    return [s.capitalize() for s in lst]

print(capitalize_list(['cat', 'dog', 'bird']))  # ['Cat', 'Dog', 'Bird']
print(capitalize_list(['apple', 'banana', 'pear']))  # ['Apple', 'Banana', 'Pear']

Write a function that takes a string as input and returns a new string with all the words reversed.

def reverse_words(s):
    return ' '.join([word[::-1] for word in s.split()])

print(reverse_words('Hello World'))  # olleH dlroW
print(reverse_words('Python is fun'))  # nohtyP si nuf