0% found this document useful (0 votes)
71 views2 pages

Python Basics Tutorial

This document provides instructions and questions for learning Python basics through online tutorials and exercises. It asks the learner to complete tutorials on variables, lists, strings, if/else statements, functions, classes, and dictionaries. The learner is then to answer 25 questions testing their understanding in these areas, paste their code and output, and email their responses for review.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views2 pages

Python Basics Tutorial

This document provides instructions and questions for learning Python basics through online tutorials and exercises. It asks the learner to complete tutorials on variables, lists, strings, if/else statements, functions, classes, and dictionaries. The learner is then to answer 25 questions testing their understanding in these areas, paste their code and output, and email their responses for review.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Python Basics

Learn and follow all exercises on the following websites:


https://www.learnpython.org/en/Hello%2C_World%21
Click "Next tutorial" every time you complete each topic until you reach the "Modules and
Packages" topic.

Then answer all the following questions. You can run the codes either on your laptop (if you
have already installed Python 3) or you can run the Python Online Compiler to test and verify
your answers at:
https://repl.it/languages/python3

Copy each of your answers and paste into this word document. Also paste your output
screenshots here.

E-mail your answer


- to [email protected]
- with the Email entitled: "[ESPEC] Python Basic Tutorial"

Variables & Type


1. How do you print an int variable and a string variable?
2. How do print a combination of int and string?
3. How do print a combination of int, float and string using string formatter/ argument
specifier?
4. How do you convert an integer variable into a float?

List/Array
5. How do you create a list/array that consists of 5 different numbers?
6. How do you iterate over an array of string e.g. [“one”, “two”, “three”] and print each
element?
7. How do you concatenate two arrays of strings and print the result?
8. How do you duplicate elements in an array?
9. How do you print the size of an array?
10. How do you print the first until the fourth element of an array?

1
11. How do you count how many occurrences of a value e.g. “one” in an array?

String
12. Create a string variable with a value of “Hello, good morning!” and print
13. Print the same variable by skipping 1 character as a full string
14. Print from the string only from the third character until the end

If/Else
15. Create a variable with an int value. If the value is greater than 10, print “Greater than 10”
message, else print “Equal or less than 10”
16. Create an array of string with three elements, e.g. “Monday”, “Tuesday”, “Wednesday”. If
the length of the second string in the array is greater than 6, print “string longer than 6
chars”

Function
17. How do you define a function that multiplies two numbers?
18. How do you call the multiply function (above) and print the result?

Class
19. How do you create a Class of Food that can be assigned a name, type (e.g. western, malay
etc) and price?
20. How do you add a function eat() to the Class Food (above) that prints different user’s
expression (“Yummy”, “Yucky”, etc) when eating the food based on the different types?
21. How do you create 3 instances of class Food and define their different properties?
22. How do you invoke the function of each class instances that print different expression
once eaten?

Dictionary
23. How do you create a dictionary object that stores different foods with their prices?
24. How do you add a new food to the dictionary?
25. How do you add a remove a food from the dictionary?

You might also like