Skip to content

Commit 618fa47

Browse files
committed
add fix_exercise_number.py script and fixed exercises numbers
1 parent 7abfb6e commit 618fa47

File tree

2 files changed

+45
-28
lines changed

2 files changed

+45
-28
lines changed

exercises.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Create a program:
112112
* Output: "I can buy 4 PS4, 1 Samsung, 3 TV, 80 game skin"
113113

114114
# ex.12
115-
You've consumed X amount of Mbps on Wikipedia and Y amount of Mbps on memes. The cost of visiting Wikipedia is 0,10$ per Mb
115+
You've consumed X amount of Mbps on Wikipedia and Y amount of Mbps on memes. The cost of visiting Wikipedia is 0,10$ per Mb
116116
and the cost for watching memes is 0,05$ per Mb. If total consumption is more than 100$ print "Too much consumption".
117117
If watching meme consumption is greater than reading wikipedia consumption print "WOW MANY MEMES", "SUCH LOL"(in new line).
118118

@@ -191,7 +191,7 @@ Create a program that:
191191
Create a program that reads a number that you want to get the sum until that number
192192

193193
Create a program that:
194-
* Reads the number you want to sum
194+
* Reads the number you want to sum
195195
* Calculates the sum of 1+2+3+4...+98+99+n
196196
* Prints the sum of 1+2+3+4...+98+99+n
197197
* Input example: 100
@@ -203,7 +203,7 @@ Create a program that:
203203
Create a program that reads a number that you want to get the sum until that number and then calculate the averge of these numbers
204204

205205
Create a program that:
206-
* Reads the number you want to sum
206+
* Reads the number you want to sum
207207
* Calculates the sum of 1+2+3+4...+98+99+n
208208
* Calculates the average of the sum 1+2+3+4...+98+99+n
209209
* Input example: 100
@@ -319,7 +319,7 @@ Create a program that:
319319
* Output: "1 Driver payed. The total earnings are 7,5$"
320320

321321
# ex.30
322-
A company asked you to create a program that reads an employee name and salary and store them into proper lists.The number of employees is unknown. To exit the program the user must input "quit". Before the exit find the employees with the maximum salary and print who they are.
322+
A company asked you to create a program that reads an employee name and salary and store them into proper lists.The number of employees is unknown. To exit the program the user must input "quit". Before the exit find the employees with the maximum salary and print who they are.
323323

324324
Create a program that:
325325
* Reads employee name and salary, store them into different lists
@@ -338,11 +338,11 @@ The previous exercise but store the names and salaries into one list.
338338

339339
#### Notice that if the programming language you are using doesn't support different kind of values in lists try to store the numbers as characters and convert to numbers when you want to compare
340340

341-
# ex.v2.1
341+
# ex.32
342342
you have a list with domain names and an other list with domain extension. also possible combinations.
343343

344-
# ex.32
345-
A company asked you to create a program that reads an employee name and salary and store them into proper lists.The number of employees is unknown. To exit the program the user must input "quit". Before the exit find and print the total number of employees and the total amount company is paying in salaries.
344+
# ex.33
345+
A company asked you to create a program that reads an employee name and salary and store them into proper lists.The number of employees is unknown. To exit the program the user must input "quit". Before the exit find and print the total number of employees and the total amount company is paying in salaries.
346346

347347
Create a program that:
348348
* Reads employee name and salary, store them into different lists
@@ -351,7 +351,7 @@ Create a program that:
351351
* Input: [Mary, John, George, Nicole], [2343, 2134, 5342, 5342]
352352
* Output: "4 employees and the total amount of salaries is 15161$"
353353

354-
# ex.33
354+
# ex.34
355355
A company asked you to create a program that reads an employee name and salary and store them into proper lists.The number of employees is unknown. To exit the program the user must input "quit". Before exit find the average salary and for each employee print if their salary is above or below average salary.
356356

357357
Create a program that:
@@ -361,7 +361,7 @@ Create a program that:
361361
* Input: [Mary, John, George, Nicole], [2343, 2134, 5342, 5342]
362362
* Output: "The average salary is 3790.25$", "Mary's salary is below average","John's salary is below average","George's salary is above average","Nicole's salary is above average"
363363

364-
# ex.34
364+
# ex.35
365365
A company asked you to create a program that reads an employee name and salary and store them into proper lists.The number of employees is unknown. To exit the program the user must input "quit". Before exit find the average salary and for each employee print if their salary is above or below average salary. If the employee have above average salary then remove the employee from the list.
366366

367367
Create a program that:
@@ -372,7 +372,7 @@ Create a program that:
372372
* Output: "The average salary is 3790.25$", "Mary's salary is below average","John's salary is below average","George's salary is above average","Nicole's salary is above average"
373373
* Output: "Total Employees: 2"
374374

375-
# ex.35
375+
# ex.36
376376
A company asked you to create a program that reads an employee name and salary and store them into proper lists.The number of employees is unknown. To exit the program the user must input "quit". Before exit find the average salary and for each employee print if their salary is above or below average salary. If the employee have above average salary then remove the employee from the list and put the employee in to a new list. Print the total number of current employees and removed emloyees
377377

378378
Create a program that:
@@ -385,15 +385,15 @@ Create a program that:
385385
* Output: "The average salary is 3790.25$", "Mary's salary is below average","John's salary is below average","George's salary is above average","Nicole's salary is above average"
386386
* Output: "Total Employees: 2", "Removed Employees: 2"
387387

388-
# ex.36
388+
# ex.37
389389
You have these lists of empoyees and their salaries: names[Mary, John, George, Nicole, Nick, Jim, Jack, Johanna], salaries[32343, 12134, 25342, 35342, 42343, 32134, 15342, 25342]
390390

391391
Create a program that:
392392
* Orders the salaries by biggest salary first
393393
* Prints all employees in order by lowest salary first
394394
* Output: "later when I run the script"
395395

396-
# ex.37
396+
# ex.38
397397
Create a program that stores all [Morse Code](https://en.wikipedia.org/wiki/Morse_code) into a dictionary. Then
398398
asks the user for an input text and translate to Morse Code.
399399

@@ -404,12 +404,12 @@ Create a program that:
404404
* Input example: "Python Rocks"
405405
* Output example: ".--. -.-- - .... --- -. / .-. --- -.-. -.- ..."
406406

407-
# ex.38
407+
# ex.39
408408
Create a program that asks if the user want to translate a text **from Morse Code** or **to Morse Code**
409409

410410
#### [Here you can find online Morse Code translator](https://morsecode.scphillips.com/translator.html)
411411

412-
# ex.39
412+
# ex.40
413413
Here is [Nato Phonetic Alphabet](https://en.wikipedia.org/wiki/NATO_phonetic_alphabet). Create a program that stores the all the abrevations into a dictionary. Next asks the user for a word and then print the right words for each letter of the given word
414414

415415
Create a program that:
@@ -421,10 +421,10 @@ Create a program that:
421421

422422
#### [Here you can find Nato Phonetic Alphabet](https://en.wikipedia.org/wiki/NATO_phonetic_alphabet)
423423

424-
# ex.40
424+
# ex.41
425425
Create a program that asks if the user want to translate a text **from Nato Phonetic Alphabet** or **to Nato Phonetic Alphabet**
426426

427-
# ex.41
427+
# ex.42
428428
A user account on a website is composed by a username, a password, if the user has profile picture, and the email.
429429

430430
Create a program:
@@ -435,7 +435,7 @@ Create a program:
435435

436436
#### Notice that the structure is like this users[username] = {'password': password, 'hasPhoto': hasPhoto, 'email': email}, word not in quotes are variables.
437437

438-
# ex.42
438+
# ex.43
439439
A user account on a website is composed by a username, a password, if the user has profile picture, and the email.
440440

441441
Create a program:
@@ -447,7 +447,7 @@ Create a program:
447447

448448
#### Notice that the structure is like this users[username] = {'password': password, 'hasPhoto': hasPhoto, 'email': email}, word not in quotes are variables.
449449

450-
# ex.43
450+
# ex.44
451451
A user account on a website is composed by a username, a password, if the user has profile picture, and the email.
452452

453453
Create a program:
@@ -459,7 +459,7 @@ Create a program:
459459

460460
#### Notice that the structure is like this users[username] = {'password': password, 'hasPhoto': hasPhoto, 'email': email}, word not in quotes are variables.
461461

462-
# ex.44
462+
# ex.45
463463
A user account on a company's website is composed by a username, a password, salary, and the email.
464464
A company asks you to create a program that create a user, ask for username,password,salary, email and check if the username or email already exists.
465465

@@ -469,30 +469,30 @@ Create a program:
469469
* Print all the users
470470

471471

472-
# ex.45
472+
# ex.46
473473
start creating users until user enter stop. check if username and email exist. check password. create user. ask user if he/she wants to delete a specific user by email or username then proceed and delete the user
474474

475475

476-
# ex.46
476+
# ex.47
477477
bank has users. users info are name, id, balance. Create users and ask for id number and balance.
478478

479-
# ex.47
479+
# ex.48
480480
bank has users. users info are name, id, balance. Create, read info(id, balance), check if user already exists. if user has 0 balance, delete account.
481481

482-
# ex.48
482+
# ex.49
483483
bank has users. users info are name, id, balance. Create, read info(id, balance), check if user already exists. if user has 0 balance, copy to a new list , delete account from active list.
484484

485-
# ex.49
485+
# ex.50
486486
bank users, info balance everything provided. Ask program for options. create user(check if user exit) if update user id(check if exist) balance(check not to be negative), if result = 0(warning! might deactivate the account, are you sure you want to procceed?)---(if no, ask for new amount ot leave). name etc.
487487

488-
# ex.50
488+
# ex.51
489489
You have two lists. The first list has the names of 5 employees and the second list has their salary. Create a dictionary with the names as key and salaries as value.
490490

491-
# ex.51
491+
# ex.52
492492
You have three lists. The first list has the names of 5 employees, the second list has their salary and the third list has how many days each employee missed. Create a dictionary with the employee name as key, salary and days missed for each employee as value
493493

494-
# ex.52
494+
# ex.53
495495
From the previous exercise find the employee with the fewest days missing.
496496

497-
# ex.53
497+
# ex.54
498498
From the previous exercise find the employee with the fewest days missing and lowest salary and give the employee a raise of 10%

fix_exercise_number.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import fileinput
2+
counter = 1
3+
4+
input_file = input('Please enter the name of the file you want to edit: ')
5+
6+
# fileinput module let us do changes in the same file
7+
with fileinput.FileInput(files=input_file, inplace=True) as f:
8+
for line in f:
9+
if line.startswith('# ex.'):
10+
replace_line = line
11+
new_line = ('# ex.{}'.format(counter))
12+
print(line.replace(replace_line, new_line))
13+
counter += 1
14+
else:
15+
print(line.strip()) # .strip() remove the extra blank lines
16+
17+
print('Editing {} successfully'.format(input_file))

0 commit comments

Comments
 (0)