- Automates the recipient writing part in the same letter.
- Recipient names are given in a separate file named invited_names.txt
- A sample letter is given in a separate file named starting_letter.txt
- Code is to be written inside main.py whose purpose is to fetch the sample letter, replace the [name] in a sample letter with recipient names & generate an individual letter following this naming convention: letter_for_{recipient_name}.txt
- The number of names given in invited_names.txt file generates a similar number of letters. Suppose, 5 names are given in invited_names.txt then, 5 letters will be generated.
Search This Blog
Python Mail Merge Project - Automating Recipient Writing in a Letter
Crossing the Turtle : Python Turtle Project for Beginners
- One turtle of unique color can only move forward.
- Neither left nor right. Turtle cannot even move backward.
- Turtle has to save itself from the collision with cars.
- If crosses all the cars, its level increases & along with all the car's speed!
- Random count cars & each car of random color are coming from the left & right.
- The scoreboard is maintained for every level.
How the game looks like?
Counting Valleys - Hackerrank Solution
Check out the counting valleys question here: Hackerrank question
The picturization of the problem:
Suppose the input is: UDDDUDUU
Then,
Answer: Valley level is 1. Because hiker stepped this way only.To solve this problem:
Initially, assumed U = 1, D = -1 & altitude=0
Then, iterated till total steps-1. Whenever altitude(height) that is sea level is 0 & the last step is 'U" I have incremented the valley by 1 (because valley level is considered only when hiker's last step is 'U" & at the sea level).
When all the elements are traversed it returned the final valley's value that's our final result.
Solution:
Sales by Match -Hackerrank solution
Check out the question here - Sales by Match
Turtle Race : Python Project for Beginners
1. 5 turtles of unique colors compete against each other.
2. User gets a chance to guess which color turtle will win the race.
3. If the user's guess is right it says you've won otherwise you lose!
Few screenshots of the game:
Doodle it: Imagine, Draw, Erase and Repeat - Python Project for Beginners
In order to create this game first step is to know a way of being able to listen to things the user does, like when a user taps a specific key on the keyboard. And the code that allows us to do this are called Event Listeners.
Go to python documentation > listen method()
It has a whole bunch of section-on-screen events, including listening to key presses or listening to a click or other things that you can listen to. So the important thing is this listen method.
Full key list for python's turtle- screen events ( Event Listeners )
Screen events
turtle.
onkey
(fun=function_name, key='Backspace')turtle.
onkeyrelease
(fun=function_name, key='Left')fun – a function with no arguments or
None
key – a string: key (e.g. “a”) or key-symbol (e.g. “space”)
.keysym | .keycode | .keysym_num | Key |
---|
Alt_L | 64 | 65513 | The left-hand alt key |
Alt_R | 113 | 65514 | The right-hand alt key |
BackSpace | 22 | 65288 | backspace |
Caps_Lock | 66 | 65549 | CapsLock |
Control_L | 37 | 65507 | The left-hand control key |
Control_R | 109 | 65508 | The right-hand control key |
Delete | 107 | 65535 | Delete |
Down | 104 | 65364 | ↓ |
End | 103 | 65367 | end |
Escape | 9 | 65307 | esc |
F1 | 67 | 65470 | Function key F1 |
F2 | 68 | 65471 | Function key F2 |
Fi | 66+i | 65469+i | Function key Fi |
F12 | 96 | 65481 | Function key F12 |
Home | 97 | 65360 | home |
Insert | 106 | 65379 | insert ( ins) |
Left | 100 | 65361 | ← |
K0 | 90 | 65438 | 0 on the keypad |
1 | 87 | 65436 | 1 on the keypad |
2 | 88 | 65433 | 2 on the keypad |
3 | 89 | 65435 | 3 on the keypad |
4 | 83 | 65430 | 4 on the keypad |
5 | 84 | 65437 | 5 on the keypad |
6 | 85 | 65432 | 6 on the keypad |
7 | 79 | 65429 | 7 on the keypad |
8 | 80 | 65431 | 8 on the keypad |
9 | 81 | 65434 | 9 on the keypad |
+ | 86 | 65451 | + on the keypad |
. | 91 | 65439 | Decimal (. ) on the keypad |
Delete | 91 | 65439 | delete on the keypad |
/ | 112 | 65455 | / on the keypad |
Down | 88 | 65433 | ↓ on the keypad |
Enter | 108 | 65421 | enter on the keypad |
Home | 79 | 65429 | home on the keypad |
Left | 83 | 65430 | ← on the keypad |
* | 63 | 65450 | × on the keypad |
Prior | 81 | 65434 | PageUp on the keypad |
Right | 85 | 65432 | → on the keypad |
- | 82 | 65453 | - on the keypad |
Up | 80 | 65431 | ↑ on the keypad |
Next | 105 | 65366 | PageDown / pg dn |
Num_Lock | 77 | 65407 | NumLock |
Pause | 110 | 65299 | pause |
Print | 111 | 65377 | PrintScrn / prt sc |
Right | 102 | 65363 | → |
Scroll_Lock | 78 | 65300 | ScrollLock |
Shift_L | 50 | 65505 | The left-hand shift key |
Shift_R | 62 | 65506 | The right-hand shift key |
Tab | 23 | 65289 | The tab key |
Turtle's random walk - Python
How to let turtle making random movements in the East, North, South, or West in Python?
Rules for Python's Turtle:
1. Each time it moves in a random direction.
2. In each direction it chooses a random color
3. Each time line's thickness increases
4. Each time it covers the same distance
5. Walks on screen in its fastest mode
Solution:
Draw different shapes like triangle, square, pentagon, hexagon in python using turtle
How to draw a triangle, square, pentagon, hexagon, heptagon, octagon, nonagon, and decagon in one go using turtle class of python?
Code:
How to draw a dashed line in python?
It's part of core python libraries so, turtle comes by default with basic python. Just need to import and use.
After importing the turtle, we use the penup and pendown to draw a dashed line. Penup simply means not drawing & Pendown is drawing a line. Like in the code below turtle module's penup & pendown are used to draw a black dashed line.
Solution to Techgig 30 Days Python Challenge - Day 7 (HARD)
Count special numbers between boundaries (100 Marks)
Input Format
For this challenge, you need to take two integers on separate lines. These numbers defines the range.Constraints
1 < = ( a , b ) < = 100000Output Format
output will be the single number which tells how many prime numbers are there between given range.Sample TestCase 1
Explanation
There are 8 prime numbers which lies in the given range.
They are 2, 3, 5, 7, 11, 13, 17, 19
- Time Limit(X):
- 1.00 sec(s) for each input.
- Memory Limit:
- 512 MB
- Source Limit:
- 100 KB
- Allowed Languages:
- C, C++, C++11, C++14, C#, Java, Java 8, PHP, PHP 7, Python, Python 3, Perl, Ruby, Node Js, Scala, Clojure, Haskell, Lua, Erlang, Swift, VBnet, Js, Objc, Pascal, Go, F#, D, Groovy, Tcl, Ocaml, Smalltalk, Cobol, Racket, Bash, GNU Octave, Rust, Common LISP, R, Julia, Fortran, Ada, Prolog, Icon, Elixir, CoffeeScript, Brainfuck, Pypy, Lolcode, Nim, Picolisp, Pike
SOLUTION DAY-07: (100 Marks)
-
Hashing to Solutions: Two Sum Longest Substring Without Repeating Characters Longest Palindromic Substring Container With Mos...
-
Hey! Here, am on Day 02 of Angela's course. Though my heading says Day 04 which is actually done to stay in order of all the python le...
-
Exploring Data Types TechGig The question asked to check out the data type of the user input. It was quite tricky as python by default conve...