🐍 Py8R
This repository was created for educational purposes. It contains 100 examples of small scripts written in Python.
💡 The Idea
A few months ago I was started playing with Python. To learn some advantages and disadvantages of these language I started reading book from Real Python series (Python 3.5). The content from the book gaves me a very good basic understanding of the language. I decided to share these samples of code for other people who wants to start with Python.
📁 Repository Structure
Some of examples have more than only one solutions. You will find them in the directory with the task.
├── Py01
├── Py02
├── Pyxx
├── Py15 # Some repositories contains more than one sample of code for one task.
│ ├── 01 # Each new solution is in separate catalog.
│ ├── main.py # And each solution is launched using the main.py file.
│ ├── 02 # Second solution for Py15
│ ├── main.py # File with second solution
├── Py100
├── README.md
📋 Examples of scripts
- Py01 - Time and date
now. - Py02 - Generate a list from values taken from input.
- Py03 - Display first and last element from list.
- Py04 - Get values from input (user) and multiply them according to the formula - (n * nn) + nnn.
- Py05 - Print calendar for all 12 months - use calendar module.
- Py06 - Print calendar for given month (from input).
- Py07 - Swap two values without temporary variable.
- Py08 - Check given number - if positive or negative.
- Py09 - Check size of an object.
- Py10 - Solve
(x * y) + (x * y) / 2^3- take values from user(input). - Py11 - Enter three values and add them. If three values are the same return zero.
- Py12 - Even/odd numbers.
- Py13 - Add
Py8Rstring to end of string. - Py14 - Count occurrence
(int)'0' in array. - Py15 - Check if array contain a
(int)'0' value. - Py16 - Concatenate elements from list in one string.
- Py17 - Calculate triangle area.
- Py18 - Add two int objects.
- Py19 - Get numbers from array divisible by 3 and 5.
- Py20 - Enter three values and calculate them (add, subtract, multiply, divide) by each other in the order entered.
- Py21 - Seconds converter. Enter day/days, hours, minutes and seconds - convert to seconds only.
- Py22 - BMI.
- Py23 - Sort integers given as function arguments
- Py24 - Concatenate strings from list.
- Py25 - Compare int values from list. If some values are greater than 10 return false otherwise return true.
- Py26 - Get ASCII for one char.
- Py27 - Filter and print negative numbers from array.
- Py28 - Filter and print positive numbers from array.
- Py29 - Filter and print zero number(s) from array.
- Py30 - Count values in array.
- Py31 - Get sum of all values from array.
- Py32 - Check if one string contain an uppercase letter(s) and another string contain an lowercase letter(s).
- Py33 - Convert int to binary.
- Py34 - Convert decimal to hexadecimal.
- Py35 - Check if variable has an int or string value.
- Py36 - Check numbers in array - if all numbers are different return true. If any number is repeated - return false.
- Py37 - Get local IP.
- Py38 - Find min value in array.
- Py39 - Find max value in array.
- Py40 - Check if file exists.
- Py41 - Count files in directory.
- Py42 - List all files in directory.
- Py43 - Write something to
.txtfile. - Py44 - Get date of creation file and last modification date of this file.
- Py45 - Change file extensions in directory. Example from
.txtto.xtt. - Py46 - Save data to CSV file.
- Py47 - Sort files by date.
- Py48 - Show full path and name of the file being executed.
- Py49 - Get size of the file being executed.
- Py50 - Extract file name from path.
- Py51 - List files from directory (without directories inside).
- Py52 - Read file.
- Py53 - Read first 'x' lines of file.
- Py54 - Append text to file and read this file.
- Py55 - Read file "line by line" and send a content from file to list,
- Py56 - Read file "line by line" and send a content from file to array.
- Py57 - Find longest word.
- Py58 - Count lines in text file.
- Py59 - The number of occurences of a word in a text file.
- Py60 - Make a file copy. Choose localisations as you want.
- Py61 - Choose one random line from text file.
- Py62 - Create all possible strings from letters
'a', 'p', 'u', 'd'. - Py63 - Return all possible permutations for values:
1, 2, 3, 4. - Py64 - Count all char occurrences in text file.
- Py65 - Length of the entered word.
- Py66 - Based on first letter - replace all chars (letters) for 'x' in provided string. If you enter word
'amphetamine'input should looks like'amphetxmine'. - Py67 - Count occurrences of each word in string.
- Py68 - Separate given string with
*character. Return the first part of this string. - Py69 - Separate given string with
_character. But this - Py70 - Get from input some number values and reverse them.
- Py71 - Take word from input. Swap first letter with last letter from word.
- Py72 - Find in string taken from input - first repeated character.
- Py73 - Find in string taken from input - first repeated word.
- Py74 - Remove spaces from string.
- Py75 - Capitalize first letter in each word in given string.
- Py76 - Convert radians to degrees.
- Py77 - Select random item from list.
- Py78 - Remove duplicate characters from string.
- Py79 - Shuffle elements from array
- Py80 - Sum of digits from string.
- Py81 - Return a random prime number (2048 length).
- Py82 - Remove duplicates from list, sort list without duplicates and print them.
- Py83 - Sum elements from list.
- Py84 - Multiply elements from list.
- Py85 - Get key/value from dictionary.
- Py86 - Print differences between two lists.
- Py87 - Merge two dictionaries.
- Py88 - Print all values from list greater than
x- 'x' is specified by yourself. - Py89 - Get smallest and largest value from list.
- Py90 - Week number.
- Py91 - Sum of all items in dictionary.
- Py92 - Find numbers divisible by 3, 5 and 7between 0 and 1000.
- Py93 - Count chars and numbers in given string.
- Py94 - Convert int to hex from 0 - 99.
- Py95 - Return random line from text file.
- Py96 - Temperature converter.
- Py97 - Print only vowels from string given by the user.
- Py98 - Remove vowels in given string by the user.
- Py99 - Simple calculator - add, subtract, multiply, divide.
- Py100 - OS information's
🐛 Bugs
If you found any problems/bugs - create an issue.
🔨 Contributing
Feel free to add a new samples or update existing.
- Fork repository
- Make a new branch branch - for relative order ;-)
- Open Pull request.