Coding Challenge 1

Program a simple game in which the user needs to guess a number in between 1 and 50. You can use the two lines below as a basis.

number = 17 guess = int( input("Guess a number in between 1 and 50: ") )

The standard function input() can be used to request a value from the user. The function int() converts the input into an integer, if possible. In your solution, try to make use of either ‘for’ or ‘while’. When the user enters a value which is too low or too high, this information must be communicated to the user via a print statement.

In [ ]:
 

Coding Challenge 2

Create two numeric variables.

first = 0 second = 1

Use these two variables to generate a Fibonacci sequence. This sequence is created by letting each new number in the sequence be the sum of the previous two numbers. If the first numbers are 0 and 1, the sequence should continue as ‘1, 2, 3, 5, 8, 13, 21’. The sequence should stop as soon as a number has reached a value higher than 200.

In [ ]:
 

Coding challenge 3

Create a list named ‘vowels’, using the following code:

vowels = ['a', 'o', 'u', 'i', 'e']

Write code in Python which can calculate the number of vowels and the number of consonants in the words stored in the following list. In your code, make use of the list of vowels that you created.

words = ['acknowledge', 'beautiful', 'contemporary', 'display', 'equivalent']

In [ ]:
 

Coding Challenge 4

Write an application which can read the full contexts of a text file on your computer, and which can list the 25 most frequent words in this text, together with their frequencies.

In [ ]:
 

Coding Challenge 5

Create a list named ‘numbers’, using the following code:

numbers = [ 4, 7, 26, 38, 43, 67, 82, 94, 111, 126, 137 ]

Write code in Python which can print the odd numbers only. In your code, make use of the modulo operator (‘%’). For more information on this operator, see: https://python-reference.readthedocs.io/en/latest/docs/operators/modulus.html

In [ ]:
 

Coding Challenge 6

Download the full text of the novel A Tale of Two Cities by Charles Dickens from the website of Project Gutenberg (Plain Text UTF-8 format). It is available at the following URL: http://www.gutenberg.org/ebooks/98

Write an application which can automatically remove the eBook header at the beginning of the file and the Project Gutenberg license which is included at the end of the file. Note that the end and the beginning of these sections are indicated explicitly, see: [https://www.gutenberg.org/wiki/Gutenberg:Project_Gutenberg_Header_How- To]

The output of the program must be written to a file named “out.txt”. In this application, it can be useful to work with a variable which determines whether or not text should be written to the output. This variable, which you could name ‘flag’, can be initialized with value ‘False’. The value may be set to ‘True’, depending on certain information found in the input file.

As you may notice, there may occasionally be some added text after the official end of the header, and before the start of the footer. You can leave these texts in the output file, for now.

See also: https://stackoverflow.com/questions/1269146/how-to-strip-headers-footersfrom-project-gutenberg-texts

In [ ]: