Posts by [email protected] (24)

Your Turn - Basics

<h2>Your Turn</h2> <p>It's' your turn now! Complete this exercise to proceed to the next topic!</p> <br> <p>1. Print the largest 6-digit number to the console.</p> <div class="kodeEditor"></div><br> <p>2. Print your name to the console.</p> <div class="kodeEditor"></div><br> <p>3. Print a paragraph from your favorite book to the console.</p> <div class="kodeEditor"></div><br> <p>Use concatenation to print the name of your favorite book and your favorite number.</p> <div class="kodeEditor"></div><br>

Concatenation

<h2>Concatenation</h2> <p>Concatenation is defined as a series of interconnected things.</p> <h3>Important things to remember</h3> <ul> <li>Sentences, words, letters and anything else that you'd enclose withing quotes in Python are called strings.</li> <li>Any kinds of numbers that are not decimal numbers are called integers.</li> <li>Numbers with decimal points are called floats.</li> </ul> <p>These types of data in Python are called data types.</p> <!-- <p>You can concatenate two of the same kind of data types, but not between</p> --> <p>To concatenate two strings you need to use the <code>+</code> operator. For example, </p> <div class="kodeEditor">print('Hello, ' + ' world!');</div> <p>You cannot actually concatenate 2 integers or floats, because using the <code>+</code> operator just adds them up.</p> <p>Note: You cannot concatenate integers and strings. To do that you need to convert the integer to a string by adding quotes around them or, if the string is a number within quotes, you need to remove them. But you don't have to this: There are 2 functions that might come in handy. They are: <code>int()</code> and <code>str()</code>. They convert strings to integers, and integers to strings, respectively. But the <code>int()</code> function has some criteria: The value, or the argument to this function has to be a string that is only an integer contained within quotes and it must not have any other letters included within the string.</p> <div class="kodeEditor">print('int('100') + '</div> <p>Next up: <a href="https://freekode.centeltech.com/course/267/">Your Turn</a></p>

1 2 3 Next Last