So what is CS50 AI all about?ĬS50's Introduction to Artificial Intelligence (AI) with Python explores the concepts and algorithms at the foundation of modern artificial intelligence, diving into the ideas that give rise to technologies like game-playing engines, handwriting recognition, and machine translation. Spoiler alert, when outlining the projects for each week I may include example code, you might want to skip over these parts if you're taking the course yourself. For example, recall the following code from lecture, which prompts the user repeatedly until they enter a positive integer.This article covers the concepts of Artificial Intelligence (AI) introduced in Harvard's CS50 Introduction to Artificial Intelligence with Python course, along with a review of the course itself, what I learned from it, and helpful advice if you're looking to start it yourself. If you want to repeatedly re-prompt the user for the value of a variable until some condition is met, you might want to use a do. Finally, your program should print the number of years required for the llama population to reach that end size, as by printing to the terminal Years: n, where n is the number of years.Your program should then calculate the (integer) number of years required for the population to reach at least the size of the end value.(After all, we want the population of llamas to grow!) If the user enters a number less than the starting population size, the user should be re-prompted to enter an ending population size until they enter a number that is greater than or equal to the starting population size.Your program should then prompt the user for an ending population size.(If we start with fewer than 9 llamas, the population of llamas will quickly become stagnant!) If the user enters a number less than 9 (the minimum allowed population size), the user should be re-prompted to enter a starting population size until they enter a number that is greater than or equal to 9.Your program should first prompt the user for a starting population size.If not, retrace your steps and see if you can determine where you went wrong! Implementation DetailsĬomplete the implementation of population.c, such that it calculates the number of years required for the population to grow from the start size to the end size. Executing code population.c should open the file where you will type your code for this lab. You should find that its “prompt” resembles the below.Īnd see a file named population.c. Start by clicking inside your terminal window, then execute cd by itself. And on the left is your file “explorer,” a graphical user interface (GUI) via which you can also explore your codespace’s files and directories. Toward the bottom of is a “terminal window”, a command-line interface (CLI) that allows you to explore your codespace’s files and directories (aka folders), compile code, and run programs. Toward the top of VS Code is your “text editor”, where you’ll write all of your programs. Once your “codespace” loads, you should see that, by default, VS Code is divided into three regions. So that you don’t have to download, install, and configure your own copy of VS Code, we’ll use a cloud-based version instead that has everything you’ll need pre-installed. ![]() Recall that Visual Studio Code (aka VS Code) is a popular “integrated development environment” (IDE) via which you can write code. 1000 / 4 = 250 llamas will pass away, so we’ll end up with a total of 1000 + 333 - 250 = 1083 llamas at the end of the year. We can’t have a decimal portion of a llama, though, so we’ll truncate the decimal to get 333 new llamas born. To try another example, if we were to start with n = 1000 llamas, at the end of the year, we would have 1000 / 3 = 333.33 new llamas. At the end of that year, we would have 1200 + 400 - 300 = 1300 llamas. ![]() Each year, n / 3 new llamas are born, and n / 4 llamas pass away.įor example, if we were to start with n = 1200 llamas, then in the first year, 1200 / 3 = 400 new llamas would be born and 1200 / 4 = 300 llamas would pass away.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |