oldoc63 / learningDS

Learning DS with Codecademy and Books
0 stars 0 forks source link

Guessing and checking with conditionals #437

Open oldoc63 opened 1 year ago

oldoc63 commented 1 year ago
oldoc63 commented 1 year ago

Using conditionals to find factors

-A factor is a number that divides evenly into another number. -In Python you can use the modulo operator (%) to calculate the remainder when dividing two numbers. For example, if a % b equals zero, it means that b divides evenly into a.

oldoc63 commented 1 year ago

The wandering turtle

oldoc63 commented 1 year ago

Creating a number-guessing game

Let's use conditionals to write an interactive number-guessing program that seems conscious. In this game I think of a number between 1 and 100, and you guess what the number is.

Making a random number generator

oldoc63 commented 1 year ago

Taking user input

oldoc63 commented 1 year ago

Converting user input to integers

oldoc63 commented 1 year ago

Using conditionals to check for a correct guess

oldoc63 commented 1 year ago

Using a loop to guess again

oldoc63 commented 1 year ago

Finding square roots

oldoc63 commented 1 year ago

Writing the squareRoot() function