Skip to content

Files

Latest commit

 

History

History
503 lines (377 loc) · 23.3 KB

File metadata and controls

503 lines (377 loc) · 23.3 KB

ex.1

Create two variables a and b, and initially set them each to a different number. Write a program that swaps both values.

  • Example: a = 10, b = 20
  • Output: a = 20, b = 10

Warning! Do not use the programming language MAGIC. After you complete the exercise feel free to do so.

ex.2

It's the end of the semester and you got your grades from three classes: Geometry, Algebra, and Physics.

Create a program that:

  1. Reads the grades of these 3 classes (Grades range from 0 - 10)
  2. Calculate the average of your grades
  • Example: Geometry = 6, Algebra = 7, Physics = 8
  • Output: average_score = 7

Warning! Do not use the programming language MAGIC. After you complete the exercise feel free to do so.

ex.9

The exercise is almost identical to a previous exercise with a minor change. It's the end of the semester and you got your marks from, Geometry, Algebra, Physics classes. If the average score is 7 and above print "Good job!", if the average score is between 6 and 4 print "You need to work harder!", if the average score is below 4 print "Failed, you really need to work harder!".

Create a program that:

  • Reads the values of these 3 lessons
  • Calculate the average of your grades
  • Example: Geometry = 6, Algebra = 7, Physics = 8
  • Output: Your average score is 7, Good job!"

Warning! Do not use the programming language magic. After you complete the exercise feel free to do so.

ex.3

You've bought a Bitcoin and now it's on the rise!!!

Create a program that:

  1. Reads the value of the bitcoin at the time of purchase
  2. Reads the percentage of increase (or decrease)
  3. Prints the total value of your bitcoin
  4. Prints the increase or decrease value
  • Example: bitcoin_value = 10000, bitcoin_increase = 10
  • Output: total_bitcoin_value = 11000, bitcoin_increase_value = 1000

ex.4

You now own some property and you want to calculate the total area of the property.

Create a program that:

  1. Reads the width and height
  2. Prints the area
  • Example: width = 5, height = 2
  • Output: total_area = 10

ex.5

You are interested in buying crypto-currencies. You want to check the current amount of money you have and see how many coins you can buy in Bitcoin, Ethereum, and Litecoin.

Create a program that:

  1. Reads the total amount of money you have
  2. Reads the price of Bitcoin, Ethereum, and Litecoin
  3. Prints the amount of Bitcoin, Ethereum, and Litecoin you can buy
  • Example: money = 100, bitcoin_price = 50, ethereum_price = 25, litecoin_price = 10
  • Output: "With 100$ you can buy: 2 Bitcoins, 4 Ethereum, and 10 Litecoins"

(Warning! Τhe prices are made up for exercise purposes)

ex.6

You are interested in buying a new laptop. You check the price and you see that the price is 300$ without the 10% tax.

Create a program that:

  1. Reads the price of the laptop
  2. Reads the tax percentage
  3. Prints the total amount
  • Output: "The total price of the laptop is 330$"

ex.7

In a company the monthly salary of an employee is calculated by: the minimum wage 400$ per month, plus 20$ multiplied by the number of years employed, plus 30$ for each child they have.

Create a program that:

  1. Reads the number of years employed
  2. Reads the number of children the employee has
  3. Prints the total amount of salary the employee makes
  • Output: "The total amount is 560$. 400$ minimum wage + 100$ for 5 years experience + 60$ for 2 kids"

ex.8

The exercise is almost identical to a previous exercise with a minor change. In a company the monthly salary of an employee is calculated by minimum wage 400$ per month, plus 20$ multiply by the employment years, plus 30$ for each employee kid, plus 100$ if the employee didn't miss 1 day of work.

Create a program that:

  • Reads the employment years
  • Reads the number of each employee kids
  • Prints the total amount the employee must take
  • Output: "The total amount is 660$, 400$ minimum wage + 100$ for 5 years experience + 60$ for 2 kids + 100$ for not missing a day at work"

ex.10

Create a program that prints the last digit of a given integer

Create a program that:

  1. Reads the integer
  2. Prints the last digit

Warning! Do not use the programming language MAGIC. After you complete the exercise feel free to do so.

Warning! Don't try to convert the number into string etc.

Warning! For this problem it's ok after spending some time to look for the solution.

ex.11

You have started working and you are wondering how many things you can buy with the money you've earned. A PS4 costs 200$, a Samsung phone 900$, a TV 500$, a game skin 9.99$

Create a program:

  • Notice that you can't but half TV or 1/4 of PS4.
  • Reads how many hours you've worked
  • Reads your hourly income
  • Prints how many items you can buy
  • Output: "I can buy 4 PS4, 1 Samsung, 3 TV, 80 game skin"

ex.12

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 and the cost for watching memes is 0,05$ per Mb. If total consumption is more than 100$ print "Too much consumption". If watching meme consumption is greater than reading wikipedia consumption print "WOW MANY MEMES", "SUCH LOL"(in new line).

Create a program that:

  • Reads X(wikipedia Mb consupmtion) and Y(watching meme Mb consumption)
  • Calculates the total consumption
  • If total consumption greater than 100$ print proper message
  • If watching meme consumption is greater than reading wikipedia articles print proper messages

Warning! For the greater meme consumption you will use one print statement and the output must be in seperate lines

ex.13

An internet cafe has 2 ways of charging. If the user is a member pays 2$/hour, Else the user pays 5$. Find if someone is a member or not and calculate the price based on how many hours the user spend. If the user is a member the tax is 10% else the tax is 20%.

Create a program that:

  • Reads how many hours the user spend
  • Check if is a member
  • Add the proper tax fee
  • Print the total amount the user has to pay
  • Output: "The user is a member stayed 2 hours for 2$/hour plus the 10% the total amount is 4.4$"

ex.14

You want to buy something from Amazon. The seller charges different prices for shipping cost based on location. For US it's 5$ for Europe it's 7$ for Canada it's 3$ for other places it's 9$

Create a program that:

  • Reads the cost of the product
  • Reads your location
  • Print the amount of money you have to pay
  • Ouput: "You have to pay 23$, 20$ for the product and 3$ for shipping cost"

ex.15

A cell phone company has the following billing policy

Fixed cost 25$
Call duration(in seconds) Charge($/per second)
1-500 0,01
501-800 0,008
801+ 0,005

Create a program that:

  • Reads how many seconds was the calls duration
  • Calculates the monthly bill for the subscriber
  • Prints the total amount
  • Output: "total amount: 48$"

Notice that that the charge for the first 500 seconds it's 0,01$ then for the next 501 to 800 seconds it's 0,008 and then it's 0,005$

ex.16

A fast food chain has these meals

Meal Price
Burger 5$
Pizza 3$
Hot Dog 1,5$

Create a program that:

  • Reads the meal the customer wants
  • Prints the cost of the meal
  • Input example: "Hot Dog"
  • Output: "Hot Dog 1,50$"

ex.17

Create a program that:

  • Calculates the sum of 1+2+3+4...+98+99
  • Prints the sum of 1+2+3+4...+98+99
  • Output: "The sum is 4950"

ex.18

  • Calculates the sum of 1+3+5+7...+99+101
  • Prints the sum of 1+3+5+7...+99+101
  • Output: "The sum is 2601"

ex.19

Create a program that reads a number that you want to get the sum until that number

Create a program that:

  • Reads the number you want to sum
  • Calculates the sum of 1+2+3+4...+98+99+n
  • Prints the sum of 1+2+3+4...+98+99+n
  • Input example: 100
  • Output: "The sum is 5050"
Try the program with a very very big number, if it takes too long check this out

ex.20

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

Create a program that:

  • Reads the number you want to sum
  • Calculates the sum of 1+2+3+4...+98+99+n
  • Calculates the average of the sum 1+2+3+4...+98+99+n
  • Input example: 100
  • Output: "The average is 50.5"

ex.21

Create a program that reads 5 numbers and find the average of these numbers

Create a program that:

  • Reads the 5 numbers you want
  • Calculates the average of these numbers
  • Input example: 4, 6, 1, 4, 9
  • Ouput: "the average is 4.8"

ex.22

Create a program that reads 5 numbers and prints if the number is negative or positive

Create a program that:

  • Reads the 5 numbers you want
  • Print if a number is negative or positive
  • Input example: 4, 6, -11, -4, 9
  • Ouput: "Positive", "Positive", "Negative", "Negative", "Positive",

ex.23

Create a program that reads numbers and sum them until the user inputs a negative value

Create a program that:

  • Reads numbers
  • Sum them
  • Prints the sum
  • Input example: 5, 9, 3, 0, 2, 0, 4, -7
  • Output: "The sum is 23"

ex.24

Create a program that reads numbers and sum them until the user inputs a negative value or zero value

Create a program that:

  • Reads numbers
  • Sum them
  • Prints the sum
  • Input example: 5, 9, 3, 7, 0
  • Output: "The sum is 24"

ex.25

You start flipping a coin, count and print how many times the result was head or tails until you enter the word "stop". Then find and print the percentage of how many head or tails was the result.

Create a program that:

  • Reads if the flipped coin was head or tails
  • If the value is "stop", print proper message and quit program
  • While value not "stop", count the result
  • Print the proper message
  • Calculates the percentage of head and tails
  • Prints the proper message
  • Input: "head", "tails", "tails", "tails", "head", "head", "tails", "tails", "tails", "head"
  • Ouput: "Head won 4 times and tails won 6 times"
  • Output: "40% Head, 60% Tails"

ex.26

Create a program that read values of apartments you want to rent until the inpute value is 0 or a negative number.

You will calculate the average price for rent and how many apartments you've registered. Print the proper message.

Then compare values of apartments you want to rent with the avarage price of the apartments you've registered until you enter 0 or a negative value.

If the price is above average price print the proper message, else if the price is below average print the proper message. If the input value is 0 or a negative number, print the proper message and exit.

Create a program that:

  • Reads values until user inputs 0 or a negative value
  • Calculates the average price
  • Counts how many apartments registered
  • Prints the average price and how many apartments registered
  • Reads prices and compare with the average price and print proper message
  • Input: 234, 764, 123, 654
  • Output: "4 apartments have registed. The average price for rent is 443.75$"
  • Input: 500, 200, 350, 450, 0, -7
  • Output: "Above average price", "Above below price", "Above below price", "Above average price", "Quit Program","Quit Program"

ex.27

Create a program that register a user with a username and a password. Then the user will try to login with the login credentials. If the user make 3 wrong attempts exit program with proper message.

Create a program that:

  • Reads the username and the password
  • Then the user try to login
  • If the user makes 3 wrong attempts exit with proper message

ex.28

Create a program that asks the user for seconds(integers values) and then start printing the countdown, when the countdown ends print Go!. If the user enters a non integer value, exit the program with proper message.

Create a program that:

  • Reads integers until user enters a non integer value.
  • Print the countdown and at the end print Go!
  • Input: 3, -7
  • Output: 3, 2, 1, Go! - Exit Program

ex.29

A Park Garage company asked you to create a program that asks if the driver is a member and then charge the driver with 1,5$ fixed cost, if the driver is not a member the fixed cost is 3$. Make sure to keep asking if the driver enters the proper response

Then asks the driver how many hours have parked. For the 1st hour the cost is 2$, for the 2nd hour the price is 1,5$ for the 3rd hour the price is 1$. From the 4th hour and after the cost is 0.5$ per hour. Make sure to keep asking the driver enters a valid value.

Finds the cost the driver has to pay and print it. Ask the user to continue the program or not.

On exit Counts and print how many drivers payed and the total amount of earnings. Ask the user to continue the program or not.

Create a program that:

  • Reads if the driver is a member or not
  • Check if the driver entered the proper response
  • Charge the driver with the proper fixed cost
  • Asks the driver how many hours have parked
  • Check if the driver entered the proper value
  • Finds how many drivers payed and the total amount of earnings
  • Input: Yes(Driver is member), 6(Hours has parked), No(exit program)
  • Output: "Total amount is 7,5$"
  • Output: "1 Driver payed. The total earnings are 7,5$"

ex.30

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.

Create a program that:

  • Reads employee name and salary, store them into different lists
  • Asks the user to continue
  • If the user wants to exit the program find and print the employees with maximum salary
  • Input: [Mary, John, George, Nicole], [2343, 2134, 5342, 5342]
  • Output: George - 5342, Nicole - 5432

Notice that we have to find the maximum salary and then compare the salaries in case someone has the exactly same salary with someone else.

ex.31

The previous exercise but store the names and salaries into one list.

  • Input : [Mary, 2343 John, 2134, George, 5342, Nicole, 5342]
  • Output: George - 5342, Nicole - 5432

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

ex.32

you have a list with domain names and an other list with domain extension. also possible combinations.

ex.33

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.

Create a program that:

  • Reads employee name and salary, store them into different lists
  • Asks the user to continue
  • If the user wants to exit the program find and print the total number of employees and total amount of salaries
  • Input: [Mary, John, George, Nicole], [2343, 2134, 5342, 5342]
  • Output: "4 employees and the total amount of salaries is 15161$"

ex.34

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.

Create a program that:

  • Reads employee name and salary, store them into different lists
  • Asks the user to continue
  • If the user wants to exit the program find the average salary and for each employee print if is above or below average salary
  • Input: [Mary, John, George, Nicole], [2343, 2134, 5342, 5342]
  • 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"

ex.35

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.

Create a program that:

  • Reads employee name and salary, store them into different lists
  • Asks the user to continue
  • If the user wants to exit the program find the average salary and for each employee print if is above or below average salary
  • Input: [Mary, John, George, Nicole], [2343, 2134, 5342, 5342]
  • 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"
  • Output: "Total Employees: 2"

ex.36

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

Create a program that:

  • Reads employee name and salary, store them into different lists
  • Asks the user to continue
  • If the user wants to exit the program finds the average salary and for each employee print if is above or below average salary
  • Removes the employee from the list if the salary is above average
  • Prints the total number of current employees and removed emloyees
  • Input: [Mary, John, George, Nicole], [2343, 2134, 5342, 5342]
  • 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"
  • Output: "Total Employees: 2", "Removed Employees: 2"

ex.37

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]

Create a program that:

  • Orders the salaries by biggest salary first
  • Prints all employees in order by lowest salary first
  • Output: "later when I run the script"

ex.38

Create a program that stores all Morse Code into a dictionary. Then asks the user for an input text and translate to Morse Code.

Create a program that:

  • Stores all Morse Code values into a dictionary
  • Asks the user for text
  • Prints the tranlsation of Morse Code
  • Input example: "Python Rocks"
  • Output example: ".--. -.-- - .... --- -. / .-. --- -.-. -.- ..."

ex.39

Create a program that asks if the user want to translate a text from Morse Code or to Morse Code

ex.40

Here is 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

Create a program that:

  • Stores the words for each letter
  • Then asks the user for a word
  • Prints the right words
  • Input example: "Python"
  • Output example: "Papa, Yankee, Tango, Hotel, Oscar, November"

ex.41

Create a program that asks if the user want to translate a text from Nato Phonetic Alphabet or to Nato Phonetic Alphabet

ex.42

A user account on a website is composed by a username, a password, if the user has profile picture, and the email.

Create a program:

  • That reads the username, password, if the user has uploaded photo or not(boolean value), and the email.
  • Stores the values into a dictionary based on username
  • Input: iakovosbelonias, 123, Yes, iakovosbelonias@gmail.com
  • Output: {'iakovosbelonias': {'password': 123, 'hasPhoto': True, 'email': 'iakovosbelonias@gmail.com'}}

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

ex.43

A user account on a website is composed by a username, a password, if the user has profile picture, and the email.

Create a program:

  • That reads the username, password, if the user has uploaded photo or not(boolean value), and the email.
  • If the email is already in the dictionary warns the user and asks again until get a valid email
  • Stores the values into a dictionary based on username
  • Input: iakovosbelonias, 123, Yes, iakovosbelonias@gmail.com
  • Output: {'iakovosbelonias': {'password': 123, 'hasPhoto': True, 'email': 'iakovosbelonias@gmail.com'}}

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

ex.44

A user account on a website is composed by a username, a password, if the user has profile picture, and the email.

Create a program:

  • That reads the username, password, if the user has uploaded photo or not(boolean value), and the email.
  • The password must be between 6 and 12 digits. Asks the user until gets a valid password
  • Stores the values into a dictionary based on username
  • Input: iakovosbelonias, 123, Yes, iakovosbelonias@gmail.com
  • Output: {'iakovosbelonias': {'password': 123, 'hasPhoto': True, 'email': 'iakovosbelonias@gmail.com'}}

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

ex.45

A user account on a company's website is composed by a username, a password, salary, and the email. 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.

Create a program:

  • Try to find on your own what the company needs
  • Test your program with various inputs
  • Print all the users

ex.46

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

ex.47

bank has users. users info are name, id, balance. Create users and ask for id number and balance.

ex.48

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.

ex.49

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.

ex.50

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.

ex.51

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.

ex.52

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

ex.53

From the previous exercise find the employee with the fewest days missing.

ex.54

From the previous exercise find the employee with the fewest days missing and lowest salary and give the employee a raise of 10%