Tag Archives | basic

python-logo

Python: Basic Questions – Functions & If Statements

Question 1: Using Functions Using a function to allow a “block of code” to take in arguments/values and returns a result. Task: Print 2*(n+1) to m using the double and increment functions provided. ‘2’ -> ‘6’ ‘0’ -> ‘2’ ‘-3’ -> ‘-4’ When given the functions: def increment(x): “”” Increment the argument (ie, return the […]

Continue Reading 0
python-logo

Python: Intro – Basic Questions

*Please note that the comments in the code, started by the hashtag, are for educational purposes and do not change the code. Question 1: Introduction: Hello, World! Printing text (e.g. Hello World) Task: Output the string ‘Hello, World!’ Answer: Explanation: Quotations are required because we want to print a string. However, if the task required […]

Continue Reading 0

Powered by WordPress. Designed by WooThemes

Free WordPress Themes