Legacy - Basic Functions
- 02:10
Learn how to use basic functions in Python.
Downloads
No associated resources to download.
Transcript
We shall now look at some basic functions that are constantly used during the process of building complex functions in Python. The first function is the print function, the print function prints the specified message onto the screen, or any other standard functions. The message can be a string or any other object. You will also have the option of printing to separate items and can also decide how to separate the items. Now, STR function converts a certain value into a string. Here, you can convert a certain integer into a string, or even a list of integers into a string. However, one thing to note is that converting the list of integers into a string would not make the separate items within the list into a string, meaning the numbers within the string list would still be integers, and we can apply operators on them. By selecting the separate objects, the individual items will not be converted into a string unless they are defined as a string. Similarly, we can use the IND function to convert strings to integer. Note that we cannot convert string words into integer but rather can only convert strings, integers, or strings numbers into integers. So for example, if we have a string defined as 1000, and if we want to convert the string into an integer in order to perform operations, we can use the IND function. The LEN function would give the length of an object meaning the number of items within the object define, for example, the list defined on the slide using the LEN function. This will return us an answer of eight as the list has eight objects defined. Finally, the input function initially provides a dialogue box to enter a value using which we can print the statement with the value entered into a dialogue box or can use the value for further functions.