Exercises for Python coding

# Practice with exbook Package

The package exbook is used for practicing basic Python programming. So far there are totally 36 questions with different difficulty levels. For the purpose of practicing, you are recommended to only use basic built-in functions like find(), min(), max() and sum(). Imported packages or more advanced functions or methods, such as sort(), argmin(), or split() should be avoided.

## Steps of running exbook

### Step 1: import the exercise book

from exbook import book as eb

len(eb)

36


The variable eb is a tuple containing 36 questions.

### Step 2: print questions

Each question can be retrieved by the corresponding indices, and can be printed by the function print().

print(eb)        # Print the first question

Define a function with two strings to be the input arguments. The output is
the summation of the numerical values of the input strings. For example, if
the input strings are "3.5"and "2.7", then the output is 6.2, as a floating
point number.

Input1: str Input2: str Output: float
Test 1: 3.5 2.7 6.2

Data Type Conversion: Easy

The printed question information includes: 1) the description of the question; 2) sample inputs and outputs; and 3) the ID and difficulty level of the question.

### Step 3: write a function to solve the question

def dtc(string1, string2):

return float(string1) + float(string2)


### Step 4: check the correctness of the question

The exbook package checks the correctness of the user-defined functions by a number of hidden tests. These tests can be run by the method check().

eb.check(dtc)

You passed 3 of the 3 tests.
The solution is correct


In case you want to know what is wrong with the tests, you may specify the argument cheat=True to show the results of these hidden tests.

eb.check(dtc, cheat=True)

Input 1: str Input 2: str Your output Correct output: float Correct
Test 1: 3.5 2.7 6.2 6.2 True
Test 2: 1.2 5 6.2 6.2 True
Test 3: 2 4 6.0 6 True
You passed 3 of the 3 tests.
The solution is correct


## Project details

This version 0.0.5 0.0.4 0.0.3 0.0.2 0.0.0

Uploaded source
Uploaded py3