Skip to content

marfotop/Python-exercises

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python exercises for a University assignment

1st exercise

A code that generates a two-dimensional array of size n x n (where n is an integer inputted by the user) filled with randomly shuffled 1s and 0s. It then checks the array for any occurrences of four consecutive 1s in a row, column, or diagonal, and counts the total number of occurrences across 99 iterations of the array. Finally, it outputs the total number of occurrences and the average number of occurrences per iteration.

2nd exercise

A code that determines whether the nth Fibonacci number is prime.

3rd exercise

A code that reads a text file and preprocesses the text by removing all non-alphabetic characters and converting the remaining text to lowercase. It then generates triads of adjacent words and uses them to create a new text by randomly selecting the next word based on the previous two words. The generated text is limited to 200 words and starts with a randomly selected triad.

4th exercise

A code that generates a grid of rows and columns specified by the user, randomly fills it with either "S" or "O", and then counts the number of occurrences of the "SOS" sequence. The program repeats this process 99 times and then calculates the total number of "SOS" sequences found and their average. The input validation is also implemented to ensure that the user inputs integers for the number of rows and columns.

About

Python exercises for a University assignment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages