0% found this document useful (0 votes)
5 views16 pages

129 - MiniProjects

The document outlines a series of mini-projects designed to teach programming concepts using Python. Each mini-project focuses on different tasks such as variable initialization, user input handling, data manipulation, and using libraries like NumPy and Pandas. The projects range from basic operations to more complex data structures and calculations.

Uploaded by

amara sacko
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views16 pages

129 - MiniProjects

The document outlines a series of mini-projects designed to teach programming concepts using Python. Each mini-project focuses on different tasks such as variable initialization, user input handling, data manipulation, and using libraries like NumPy and Pandas. The projects range from basic operations to more complex data structures and calculations.

Uploaded by

amara sacko
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Mini-project 1

• Create a folder in your workspace and open Jupyter Notebook in this folder.
• Create a notebook named “miniproject1.ipynb”
• Initialize 3 variables (a, b, c) and set values as given below :
• Variable “a” has a value of 8
• Variable “b” has a value of 9
• Variable “c” has a value of 10

• Write a code to print the 3 variables


• Run the code
Mini-project 2

• Write a program to ask a user his name, his first name and his age. The program must stock
the 3 values input by user in 3 variables called “name”, “first_name” and “age”.

• Check the type of 3 variables with type() function.

• Convert the variable “age” into integer type with int() function.

• Check the type of “age”


Mini-project 3

• Bryan has 5 children : Joe, Katie, Maddy, John & William. He has a bag of 73 sweets.

Bryan wants to share all sweets between children, but Katie is punished. Bryan decides to share
sweets between Joe, Maddy, John & William. Katie will have the rest.

A. Write a program to help Bryan to share sweets. The variable sweets_per_children must store
the number of sweets per children and the variable sweets_for_katie have to store the
number of sweets for Katie.
B. Print these variables
Mini-project 4

• Dave is a museum director. He askes you to write a program to help him to sell tickets. The
price of tickets are :
• Child Tickets (< 11 y.o) = free
• Teenager Tickets (>= 11 y.o & < 18 y.o) = 5$
• Adult Tickets (>= 18 y.o & <= 65 y.o) = 10$
• Senior Tickets (> 65 y.o) = 7.5 $

• Write a program designed to calculate the price of tickets depending on number of tickets
sold and age of customers
Mini-project 5

• Joe learns the multiplication tables.

• Write a program with a for loop to display the multiplication tables from 1 to 10
Mini-project 6

• You’ll code a mini-game ! The aim of game is to find a random number between 1 and 1000 in
5 try.

• The program must pick a random number between 1 and 1000 and ask to player a number
while the player does not find the correct number.

• The player has a maximum of 5 try.

• Program have to display if the number input is higher or lower than random number

Help to pick a random number :


import random
number = random.randint(1,1000)
Mini-project 7

• Joe is a meteorologist. He has a list of temperatures recorded on a station.

temperatures = [4,9,3,0,1,12,8]

• Write a program to calculate the average of this list.


Mini-project 8

• Mark is a seller in a computer shop. He has 5 computers and ran a benchmark software on
these computers (see results below).

Results :

Computer A Computer B Computer C Computer D Computer E


CPU Score 1320 1500 2000 1850 2300
GPU Score 2200 1800 2349 2765 3905

• Store data of computer in a list of dictionnary:


computer_A = {“name”: “computer_a”, “scores”: (1320,2200)}

• Calculate the average CPU score & average GPU score for all computers
Mini-project 9

• Store in variable “a” the second element of the first array in this 2D array.
two_d = np.array[[4,5,6,8,10],[9,4,5,8,10]]

• Store in variable “b” the first element of the second array in this 2D array above
Mini-project 10

• Multiplication tables again ! Code a program to display multiplication tables from 1 to 10 with
“np.full()” method. Create a 1D np-array with all tables.

Example for 0 table :

table_zero = np.full(11,0)

for n in range(len(table_zero)):
table_zero[n] = table_zero[n]*n
Mini-project 11

Joe has a mathematic exercise : he has to subtract 4 of matrix (see below) and add 8.Then, he
has to multiply the matrix by 6 Write a program to do it.

• Declare this variable :


• matrix = np.array([[5,9,3,4],[9,2,4,6]])
Mini-project 12

• Transpose this matrix

matrix=np.array([[1,4,8], [9,4,3]])
Mini-project 13

• James, a meteorologist has a monthly report of temperatures in the form of Python list of
dictionaries.

reports = [{'day': 1, 'temperature': 0}, {'day': 2, 'temperature': 12}, {'day': 3, 'temperature': 17}, {'day': 4, 'temperature': 5},
{'day': 5, 'temperature': 12}, {'day': 6, 'temperature': -2}, {'day': 7, 'temperature': 8}, {'day': 8, 'temperature': 2}, {'day': 9,
'temperature': 13}, {'day': 10, 'temperature': 2}, {'day': 11, 'temperature': 16}, {'day': 12, 'temperature': 3}, {'day': 13,
'temperature': 13}, {'day': 14, 'temperature': -4}, {'day': 15, 'temperature': 10}, {'day': 16, 'temperature': -4}, {'day': 17,
'temperature': 15}, {'day': 18, 'temperature': 16}, {'day': 19, 'temperature': 17}, {'day': 20, 'temperature': -2}, {'day': 21,
'temperature': 0}, {'day': 22, 'temperature': -4}, {'day': 23, 'temperature': 8}, {'day': 24, 'temperature': 15}, {'day': 25,
'temperature': 7}, {'day': 26, 'temperature': -3}, {'day': 27, 'temperature': 8}, {'day': 28, 'temperature': 13}, {'day': 29,
'temperature': 8}, {'day': 30, 'temperature': 17}, {'day': 31, 'temperature': 2}]

• Basing on this list, create a 1D np array in the form below :

reports = np.array(temp1, temp2, …])

• Find the minimum, maximum, mean & median temperatures recorded during the month with
numpy methods.
Mini-project 14

• Jim had his marks in French lessons. He wants put his marks into a Pandas data structures.
Create a DataFrame based on this array :

marks = [[15,18],
[13,14],
[12,11]]

The name of columns of Data Frame are “Vocabulary”, “Oral comprehension”.


Mini-project 15

• Jim had his marks in French lessons. He wants put his marks into a Pandas data structures.
Create a DataFrame based on this dictionnary :

marks = {“vocabulary”:[10,14,16], ”oral_comprehension”:[18,12,14]}


Mini-project 16

• Paul is the owner of a computer shop. He has received some CPUs :

cpus = {“id_inventory”:[”AX34H89”, ”BV89A32”, ”PO45N40”], “name”:[”Intel Core I3”, ”Intel Core


I5”, ”Intel Core I7”], “price”:[140,250,400]}

• Create a dataframe based on this dictionary

• Set “id_inventory” to index column.

You might also like