Code Monkey home page Code Monkey logo

python-exercises's Introduction

Python Exercises

Exercises solved in the Python 3 course from Curso em Vídeo

World 1: Fundamentals


Introduction

Ex001: Create a program that says “Hello, World!” on the screen.

Ex002: Make a program that reads a person’s name and displays a welcome message.

Primitives Types

Ex003: Create a program that reads two numbers and shows the sum between them.

Ex004: Create a program that reads something on the keyboard and shows on the screen the primitive type and all possible information about it.

Arithmetic Operators

Ex005: Create a program that reads an integer and shows your successor and predecessor on the screen.

Ex006: Create a program that reads a number and shows your double, triple and square root.

Ex007: Develop a program that reads two notes of a student, calculates and displays their average.

Ex008: Write a program that reads a value in meters and displays it converted to centimetres and millimetres.

Ex009: Make a program that reads any integer and shows your multiplication table on the screen.

Ex010: Create a program that reads how much money a person has in their wallet and shows how many dollars they can buy. Consider: US$1.00 = R$5.31.

Ex011: Make a program that reads the width and height of a wall in meters, calculate its area and the amount of paint needed to paint it. Consider that each liter of paint paints an area of 2m².

Ex012: Make an algorithm that reads the price of a product and shows its new price, with 5% discount.

Ex013: Make an algorithm that reads an employee’s salary and shows his new salary, with a 15% increase.

Ex014: Write a program that converts a temperature by typing in degrees Celsius and converting it to degrees Fahrenheit.

Ex015: Write a program that asks the number of kilometres a car has driven and the number of days it has been hired. Calculate the price to pay, knowing that the car costs US$ 60 per day and US$ 0.15 per km driven.

Working with Modules

Ex016: Create a program that reads a real number from the keyboard and shows the entire portion on the screen.

Ex017: Make a program that reads the length of the opposite side and the adjacent side of a right angled triangle calculate and show the length of the hypotenuse.

Ex018: Make a program that reads any angle and shows on the screen the value of the sine, cosine and tangent of that angle.

Ex019: A teacher wants draw one of his four students to erase the board. Make a program that helps him, reading their name and writing the name of the chosen one.

Ex020: The same teacher from the previous challenge wants to raffle off the order in which students present their work. Make a program that reads the names of the four students and shows the order drawn.

Ex021: Make a Python program that opens and plays audio from an MP3 file.

Manipulating Text

Ex022: Create a program that reads a person’s full name and displays: The name with all uppercase letters; The name with all lowercase letters; How many letters in total (without considering spaces); How many letters have the first name.

Ex023: Make a program that reads a number from 0 to 9999 and shows each of digit separately on the screen.

Ex024: Create a program that reads a name of a city and says whether or not It begins whit the name ‘Santo’.

Ex025: Create a program that reads a person’s name and tells them if they have ‘Silva’ in their name.

Ex026: Make a program that reads a sentence on the keyboard and shows: How many times the letter ‘A’ appears; In what position does it appear the first time; In what positions does it appear the last time.

Ex027: Make a program that reads a person’s full name, then shows the first and last names separately.

Conditions (Part I)

Ex028: Write a program that makes the computer “think” of an integer between 0 and 5 and ask the user to try to find out which number was chosen by the computer. The program should write on the screen if the user won or lost.

Ex029: Write a program that reads a velocity by a car. If he exceeds 50 m/h, show a message saying he was fined. The fine will cost US$ 7.00 for every mile over the limit.

Ex030: Create a program that reads an integer and shows on the screen whether it is even or odd.

Ex031: Develop a program that asks the distance of a trip in miles. Calculate the fare price, charging $ 0.50 per mile for trips up to 200 miles and $ 0.45 for longer trips.

Ex032: Make a program that reads any year and shows if it is a leap year.

Ex033: Make a program that reads three numbers and shows which is the largest and which is the smallest.

Ex034:Write a program that asks for an employee’s salary and calculates the amount of your increase. For salaries in excess of US$ 1,250.00, calculate an increase of 10%. For those less than or equal, the increase is 15%.

Ex035: Develop a program that reads the length of three lines and tells the user whether or not they can form a triangle.

World 2: Control Structures


Conditional Statements

Ex036: Write a program to approve the bank loan for the purchase of a home. The program will ask for the value of the house, the buyer’s salary and how many years he will pay. Calculate the monthly instalment amount, knowing that it cannot exceed 30% of the salary or the loan will be denied.

Ex037: Write a program that reads any integer and ask the user to choose the conversion base:1 for binary; 2 for octal; 3 for hexadecimal.

Ex038: Write a program that reads two integer and compares them, showing a message on the screen. The first value is greater; The second value is greater; There is no greater value, the two are equal.

Ex039: Make a program that reads the year of birth of a young person and reports, according to their age: If he is still going to enlist in the military; If it’s time to enlist; If you are past the time of enlistment. Your program should also show how much time is left or past the deadline.

Ex040: Create a program that reads 2 notes from a student and calculates their average, showing a message at the end, according to the average achieved: Average below 5.0: Fail; Average between 5.0 and 6.9: Recovery; Average 7.0 or higher: Approved.

Ex041: The National Swimming Confederation needs a program that reads the year of birth of an athlete and shows his category, according to age. Up to 9 years: Child; Up to 14 years: Infant; Up to 19 years: Junior; Up to 25 years: Senior; Above: Master.

Ex042: Develop a program that reads the length of three sides and tells the user whether or not they can form a triangle. And if they can form, show on the screen what kind of triangle will be formed: Equilateral: all sides equal; Isosceles: two equal sides; Scalene: all different sides.

Ex043: Develop a logic that reads the weight and the height of a person, calculate their BMI and show their status, according to the table below. under 18.5: underweight; between 18.5 and 25: ideal weight; 25 to 30: overweight; 30 to 40: obesity; Above 40: morbid obesity.

Ex044: Develop a program that calculates the amount to be paid for a product, considering its normal price and payment terms. In cash/check: 10% discount; On the Card: 5% discount; Up to 2 times on the card: normal price; 3 times or more on the card: 20% interest.

Ex045: Create a program that makes the computer play Jokenpo with you.

for Loop

Ex046: Make a program that shows on the screen a countdown to the burst of fireworks, going from 10 to 0, with a 1 second pause between them.

Ex047: Create a program that shows on the screen all the even numbers that are in the range between 1 and 50.

Ex048: Make a program that calculates the sum between all the odd numbers that are multiples of three and that are in the range of 1 to 500.

Ex049: Redo ex009, showing the multiplication table of a number that the user chooses, only now using a for loop.

Ex050: Develop a program that reads 6 integers and shows the sum of only those that are even. If the value entered is odd, disregard it.

Ex051: Develop a program that reads the first term and the reason for an arithmetic progression. At the end, show the first 10 terms of this progression.

Ex052: Make a program that reads an integer and says whether or not it is a prime number.

Ex053: Create a program that reads any sentence and says if it is a palindrome, disregarding spaces.

Ex054: Create a program that reads the birth year of seven people. At the end, show how many people have not yet reached the age of majority (>= 21) and how many are of legal age.

Ex055: Make a program that reads the weight of five people. At the end, show what was the highest and lowest weight read.

Ex056: Develop a program that reads the name, age and sex of four people. At the end of the program, show: The mean age of the group; What is the name of the oldest man; How many women are under twenty.

while Loop

Ex057: Make a program that reads a person’s gender, but only accepts the ‘M’ or ‘F’ values. If it is wrong, ask for the typing again until it has a correct value.

Ex058:Improve the game in exercise ex028 where the computer will “think” of a number between 0 and 10. Only now the player will try to guess until he gets it right, showing in the end how many guesses it took to win.

Ex059: Create a program that reads two values and shows a menu on the screen: [1] ADD; [2] MULTIPLY; [3] BIGGER; [4] NEW NUMBERS; [5] EXIT PROGRAM. Your program must perform the requested operation in each case.

Ex060: Make a program that reads any number and shows it’s factorial.

Ex061: Redo exercise ex051, reading the first term and the reason for an arithmetic progression (AP), showing the first 10 terms of the progression using the while structure.

Ex062: Improve exercise ex061 by asking the user if he wants to show a few more terms. The program ends when he says he wants to show 0 terms.

Ex063: Write a program that reads any integer “n” and shows the first “n” elements of a Fibonacci sequence on the screen. Ex. 0 ⇢ 1 ⇢ 1 ⇢ 2 ⇢ 3 ⇢ 5 ⇢ 8.

Ex064: Create a program that reads several integers from the keyboard. The program will only stop when the user enters the value 999, which is the stop condition. At the end, show how many numbers were entered and what was the sum between them (disregarding the flag).

Ex065: Create a program that reads several integers from the keyboard. At the end of the run, show the average of all values and which was the highest and lowest values read. The program should ask the user whether or not he wants to continue to enter the values.

Interrupting while Repetition

Ex066: Create a program that reads several integers from the keyboard. The program will only stop when the user enters the value 999, which is the stop condition. At the end, show how many numbers were entered and what was the sum between them (disregarding the flag).

Ex067: Make a program that shows the multiplication table of several numbers, one at a time, for each value entered by the user. The program will be interrupted when the requested number is negative.

Ex068: Make a program that plays Odds or Evens with the computer. The game will only be stopped when the player loses, showing the total number of consecutive victories he has won at the end of the game.

Ex069: Create a program that reads the age and sex of several people. For each registered person, the program should ask if the user wants to continue or not. At the end, it shows: A) How many people are over 18 years old. B) How many men were registered. C) How many women are under 20 years old.

Ex070: Create a program that reads the name and price of various products. The program should ask if the user will continue. At the end, show: A) What is the total spend on the purchase. B) How many products cost more than US$ 1000.00. C) What is the cheapest product name.

Ex071: Create a program that simulates the functioning of an ATM. At the beginning, ask the user what will be the amount to be withdrawn (whole number) and the program will inform how many bills of each amount will be delivered. Consider that the ATM has banknotes of US$50, US$20, US$10 and US$1.

World 3: Composite Structures


Tuple

Ex072: Create a program that has a tuple fully populated with a count in full, from zero to twenty. Your program should read a number on the keyboard (between 0 and 20) and show it in full.

Ex073: Create a tuple filled with the top 20 in the Premier League table, in order of placement. Then show: A) Only the top 5 B) The last 4 placed in the table; C) An alphabetical list of teams; D) What position on the table is Manchester United.

Ex074: Create a program that will generate five random numbers and place it in a tuple. After that, show the list of generated numbers and also indicate the lowest and highest values that are in the tuple.

Ex075: Develop a program that reads four values from the keyboard and stores them in a tuple. At the end, show: A) How many times did the value 9 appear. B) In which position the first value 3 was entered. C) What were the even numbers.

Ex076: Create a program that has a unique tuple with product names and their respective prices, next. At the end, show a price list, organizing the data in tabular form.

Ex077: Create a program that has a tuple with several words (do not use accents). After that, you must show, for each word, what are your vowels.

List (Part I)

Ex078: Make a program that reads 5 numeric values and saves them in a list. At the end, show which was the highest and lowest value entered and their respective positions in the list.

Ex079: Create a program where the user can enter several numeric values and register them in a list. If the number already exists inside, it will not be added. At the end, all the unique values entered will be displayed, in ascending order.

Ex080: Create a program where the user can enter five numeric values and register them in a list, already in the correct insertion position (without using the sort ( )). At the end, show the ordered list on the screen.

Ex081: Create a program that will read several numbers and put them on a list. After that, show: A) How many numbers were entered. B) The list of values, ordered descending. C) Whether value 5 was entered and whether or not it is in the list.

Ex082: Create a program that will read multiple numbers and put them in a list. After that, create two extra lists that will contain only the even values and the odd values entered, respectively. At the end, show the content of the three lists generated.

Ex083: Create a program where the user types any expression using parentheses. Your application should analyse whether the expression passed is with open and closed parentheses in the correct order.

List (Part II)

Ex084: Make a program that reads the names and weight of several people, keeping everything in a list. At the end, show: A) How many people were registered. B) A listing with the heaviest people. C) A listing with the lightest people.

Ex085: Create a program where the user can enter seven numerical values and register them in a single list that keeps the odd and even values separate. At the end, show even and odd values in ascending order.

Ex086: Create a program that creates a 3x3 dimension matrix and fills in values read from the keyboard. At the end, show the matrix on the screen, with the correct formatting.

Ex087: Improve the previous exercise, showing at the end: A) The sum of all typed even values. B) The sum of the values in the third column. C) The highest value of the second line.

Ex088: Make a program that helps a PowerBall player to make guesses. The program will ask how many games will be generated and will raffle 6 numbers between 1 and 60 for each game, registering everything in a composite list.

Ex089: Create a program that reads the name and two notes of several students and stores everything in a compound list. At the end, show a bulletin containing the average of each one and allow the user to show the grades of each student individually.

Dictionary

Ex090: Make a program that reads a student's name and average, and also stores the situation in a dictionary. At the end, show the content of the structure on the screen.

Ex091: Create a program where 4 players roll a die and have random results. Store these results in a dictionary. In the end, put this dictionary in order, knowing that the winner has the highest number in the die.

Ex092: Create a program that reads name, year of birth and work permit and records them (with age) in a dictionary, if by chance the National Insurance Number (NI number) is different from zero, the dictionary will also receive the year of hire and salary. Calculate and add, in addition to age, how old the person will retire (35 years of contribution).

Ex093: Create a program that manages the performance of a football player. The program will read the player’s name and how many matches he has played. Then It will read the number of goals scored in each match. In the end, all of this will be kept in a dictionary, including the total goals scored during the championship.

Ex094: Create a program that reads the name, sex and age of several people, saving each person's data in a dictionary and all dictionaries in a list. At the end, show: A) How many people were registered; B) The average age of the group; C) A list of all women; D) A list of all above average people.

Ex095: Enhance Ex093 so that it works with multiple players, including a system for viewing details of each player's performance.

python-exercises's People

Contributors

mcleitao avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.