Those of you who have completed Code Academy and My blog lessons will find these equations straightforward and will know where to look for answers. I would like you to open a google document and/ or a Word document. Put your name and the date at the top and give it the title Python. Answer the questions. Take screen shots of the code you have run in
Skulptor and upload photo onto the word doc. When you are finished upload the word document into a Scribd doc in your assignment section on your Weebly. Word documents work best, so if you make it a google doc, convert it when you are finished. If you do not know how to convert a google document to a word document please ask me to help.
To have your assignment listed as "on time" you will have to have it posted on your Weebly by the end of class on Friday, May 26th.
Python:
1. This coding language is used best for what kinds of programming? (at least three examples)
2. Define a function:
a) my favourite subject is __________
b) This summer I hope to __________
c) When I graduate, I will___________
3. Correct this code so it will run.
if 10>9 print (Ten is greater than 9)
4. Create a coder message appropriate to this piece of code (hint: #)
x=25
y= Heeeers Johnny!
5. create your own variable that prints, I am in grade ____!
6.What can a variable start with and what can it not?
a) b) c) d)
7. Define a variable for x and print this command with x as your variable.
("Python is" + x)
8.Define a function called I <3 pizza * yes, it can be your own favourite food
9. Parameters:
Create a code using parameters that defines your last name and when run gives each of your family members your last name.
10. Define a function for which country you are from. Try this out with at least four different countries.
11. Define my function as (x). x will be the multiplication table 4. give me the 4 times table from 1-10.
12. Using lambda define a doubler and tripler function for the number 25
13. lists and loops
a) Create a list of favourite sports, computer games, activities
b) Create a break for one your lists
c) ask it not to print one of the items on each of your lists
Bonus:
Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.
Extras:
- Add on to the previous program by asking the user for another number and printing out that many copies of the previous message. (Hint: order of operations exists in Python)
- Print out that many copies of the previous message on separate lines. (Hint: the string
"\n
is the same as pressing the ENTER button)
User input in Python
To get user input in Python (3), the command you use isinput()
.
Store the result in a variable, and use it to your heart’s content.
Remember that the result you get from the user will be a string, even if
they enter a number.For example,
What this will print in the terminal (or the shell, whatever you are running Python in) will be:
What happens at the end of
input()
is that it waits for the user to type something and press ENTER. Only after the user presses ENTER does the program continue.Here is a link to W3school Python that may help .
Good Luck!
No comments:
Post a Comment