Skip to main content

Exercises for Python coding

Project description

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[0])        # 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[0].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[0].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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

exbook-0.0.5.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

exbook-0.0.5-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file exbook-0.0.5.tar.gz.

File metadata

  • Download URL: exbook-0.0.5.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.7

File hashes

Hashes for exbook-0.0.5.tar.gz
Algorithm Hash digest
SHA256 e4c40ba01c6f48feda3fdda265a12132bcc5a8490d2863bc53c7b48f610fd704
MD5 5f4998e8f2a24bdb764e823d5424747b
BLAKE2b-256 cd6221b1f7742461733fb78993affc642fdd6db1232380bdf9b58f95fe0af640

See more details on using hashes here.

File details

Details for the file exbook-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: exbook-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.7

File hashes

Hashes for exbook-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0d052792d6928ebb627bf4524cad59cbac41993024ba2b47ef3e78167e758398
MD5 cedac5836759273ebd9b29708a1e5d94
BLAKE2b-256 6f10bb3140978602ad8ff33dbb93d5f10d9653697e1500003d74c39fe0dd2f56

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page