Practice: Basics and Datatypes
💡 This is your chance to put what you’ve learned into action.
Try solving these practice challenges to check that you understand the concepts.
Why practice?
Practice coding helps you become a great coder. These practice problems aren't graded, but that doesn't mean they aren't important.
You should aim to practice a lot, especially with unfamiliar concepts. Spread practice over multiple days to take advantage of the spacing effect, which helps you retain new knowledge.
More about practice
Practice helps you understand what you know, and what you don't know. It can be easy to trick yourself into thinking you understand something when you do not -- or that you don't understand when you do. Practicing by writing code or debugging code will help you find out what you really understand, and where you are still confused.
Practice helps build confidence in your coding. The more programs you write, and the more problems you solve, the more you learn that you are a capable coder and problem-solver.
Practice doesn't always feel good - sometimes you'll be stumped! But, practice shouldn't feel super frustrating either. If you find yourself getting angry at yourself or the code, it's a good time to take a break and ask for help.
On the flip side, if practice feels too easy, it means you aren't challenging yourself enough. If the practice problems early in the course are not challenging for you, take a look at the Additional Practice page. You should still complete these exercises, so that you can confirm that you can apply these concepts
The solutions to some challenges are available, and you can view a video of the solution below each challenge.
- Try to go through the whole challenge without using the solution.
- If you can’t do the challenge without looking the solution, it means you don’t understand the material well enough yet.
- Try the next practice challenges without looking at the solution. If you need more practice challenges, reach out on Discord.
Submission
Reminder: This practice is not graded. You should submit your work on Github Classroom so that your instructor can check your code, but you will not normally get feedback on the practice assignments.
This video shows how to get assignment code onto your computer, and how to submit it to Github Classroom. You can ignore the parts about submitting in Gradescope and Woolf for the practice exercises.
Video
Body Mass Index
This is 1 of the assignment problems for this week. You can check your solution against the solution provided here. The video also walks you through the process of arriving at your solution. Your code doesn't have to look exactly like what is shown here for it to be correct. There are many other correct solutions.
💪🏿 Create a program that calculates body mass index, which is used to determine if a person's weight is a healthy proportion for their height.
Follow the link below to attempt this exercise (that attempt can be submitted as part of your required assignment)
Watch the video below to see the full solution.
Make sure you give yourself enough time to solve the practice without watching the video. It is really important for your learning.
Body Mass Index Solution
Decryption
Encryption and decryption play an important role in information security and computer science. It’s used everywhere to secure the transmitted data between two entities. In this exercise, we have a sample program that decrypts secret messages. In this task, you will follow some steps to decrypt a secret message.