Skip to content

Abd2023/bootcamp-Python-exercises

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

bootcamp-Python-exercises

Python exercises with the structures if else, for loop, while loop and range(), along with their solutions Exercise: Create a new list from two lists using the following condition. Given two lists of numbers, write a program to create a new list so that the new list should contain the odd numbers of the first list and the even numbers of the second list.

Exercise: Write a program to count the total number of digits in a number using a while loop. For example, the number is 75869, so the result should be 5.

Python Functions Exercise Exercise: Given two integers, return their product only if it is equal to or less than 1000, otherwise return their sum.

Python List Exercise Exercise: Remove all occurrences of a specific item from a list. Given a Python list, write a program to remove all occurrences of item 20.

Python tuple exercise Exercise: Copy specific elements from a tuple to a new tuple Write a program to copy elements 44 and 55 of the next tuple into a new tuple.

Python Dictionary Exercise Exercise: Create a dictionary by extracting keys from a given dictionary Write a Python program to create a new dictionary by extracting the mentioned keys from the dictionary below. sample_dict = { "name": "Kelly", "age": 25, "salary": 8000, "city": "New York"} *keys to extract = ["name", "salary"] résultat attendu : {'name': 'Kelly', 'salary': 8000}

Python Dictionary Exercise Exercise: Create a dictionary by extracting keys from a given dictionary Write a Python program to create a new dictionary by extracting the mentioned keys from the dictionary below. sample_dict = { "name": "Kelly", "age": 25, "salary": 8000, "city": "New York"} *keys to extract = ["name", "salary"] résultat attendu : {'name': 'Kelly', 'salary': 8000}

Object-Oriented Programming (OOP) Exercise in Python: Exercises on Classes and Objects Exercice POO : Create a Class with Instance Attributes Write a Python program to create a Vehicle class with instance attributes max_speed (maximum speed) and mileage (mileage).

OOP Exercise : Class Inheritance Given: Create a Bus child class that inherits from the Vehicle class. The default fare charge of any vehicle is seating capacity * 100. If Vehicle is Bus instance, we need to add an extra 10% on full fare as a maintenance charge. So total fare for bus instance will become the final amount = total fare + 10% of the total fare. Note: The bus seating capacity is 50. so the final fare amount should be 5500. You need to override the fare() method of a Vehicle class in Bus class.

Exercice Python JSON (Javascript Object Notation) Exercise: Access the value of key2 from the following JSON

Exercise: Sort JSON keys and write them to a file Sort the following JSON data in alphabetical order by keys sampleJson = {"id" : 1, "name" : "value2", "age" : 29} Expected result: { "age": 29, "id": 1, "name": "value2" }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published