PYTHON DICTIONARY
CommentsData typesVariablesIf ElseIf Elif ElseFunctionsFor loopWhile loopData structuresString slicingUser defined functionLocal/Global variableValidation and TryMethodsFile I/OPseudocodeModules |
What is a function?
What functions do i need to know?As many as possible, but here is a list of functions that you will find useful:
Python challenge - print() functionEnter the following code in a Python code editor. Before running the code, what do you think it will do? Press "F5" then "Enter" to run
Change both instances of "FastFood" to "BestFriend" and then change "KFC" to the name of your best friend. What happens now? The print() function allows for data to be displayed to the screen
Python challenge - input() functionEnter the following code in a Python code editor. Before running the code, what do you think it will do? Press "F5" then "Enter" to run
Can you enter a combination of letters, numbers and symbols?
Python challenge - float() functionEnter the following code in a Python code editor. Before running the code, what do you think it will do? Press "F5" then "Enter" to run
In this code, you are asking someone to the price of a song on Itunes BUT you are specifying that the data they enter is a float(). Why do we generally express prices as a float and not an int? (also we are using the function input() which displays the question on the screen and prompts the user to enter information using the keyboard
Python challenge - int() functionEnter the following code in a Python code editor. Before running the code, what do you think it will do? Press "F5" then "Enter" to run
In this code, you are asking someone to enter their age BUT you are specifying that the data they enter is an int() or Integer. Why do we generally express how old we are as an int and not a float? (also we are using the function input() which displays the question on the screen and prompts the user to enter information using the keyboard
Python challenge - str() functionEnter the following code in a Python code editor. Before running the code, what do you think it will do? Press "F5" then "Enter" to run
In this code, you are asking someone to enter their name BUT you are specifying that the data they enter is an str() or string. Why do we generally express how old we are as a string and not an int? (also we are using the function input() which displays the question on the screen and prompts the user to enter information using the keyboard
Python challenge - help() functionEnter the following code in a Python SHELL and press enter
What happens? Now, in the brackets, type any of the function e.g. help(int) or help(str). What is being displayed? Is this useful to you?
Python challenge - len() functionEnter the following code in a Python SHELL and press enter
What happens? Run it again but change the string
Python challenge - type() functionEnter the following code in a Python SHELL and press enter
What happens? Run it again but change the data type
Python challenge - range() functionEnter the following code in a Python code editor. Before running the code, what do you think it will do? Press "F5" then "Enter" to run
What happens? Change the value of 10 to 20 and see what is happens. Now in the brackets put the following values (5,10) and see what happens. Now in the brackets put the following values (2,26,2) and see what happens. Now in the brackets put the following values (3,39,3) and see what happens. Can you explain what the values in the brackets are doing?
Python challenge - round() functionEnter the following code in a Python code editor. Before running the code, what do you think it will do? Press "F5" then "Enter" to run
What happens? What if you change the the (, 2)to (, 3)?
|