Important Announcement
PubHTML5 Scheduled Server Maintenance on (GMT) Sunday, June 26th, 2:00 am - 8:00 am.
PubHTML5 site will be inoperative during the times indicated!

Home Explore Pratical exercices

Pratical exercices

Published by raynblh4, 2023-08-01 19:15:07

Description: Are you ready to embark on an exhilarating journey through the world of programming? Whether you're a complete beginner or an experienced developer looking to level up your skills, "From Novice to Ninja: The Ultimate Coding Exercise Book" has got you covered!
This comprehensive and thoughtfully curated book is designed to take you from the very basics of coding to the heights of advanced programming. With a carefully crafted progression of exercises, you'll build a strong foundation and steadily enhance your coding prowess as you advance through the chapters.

Search

Read the Text Version

CloudCSrest Unlocking the PrSoegcrrae mtsmoifng Belhadj Ahmed Rayane Hocine

Inside these pages, you'll explore a wide range of programming concepts, including variables, loops, conditionals, functions, and more. Each exercise is thoughtfully designed to provide not only practical knowledge but also an opportunity to unleash your creativity and problem-solving skills. No matter your background or age, the world of programming welcomes everyone with open arms. So, dive into this book with enthusiasm, embrace the challenges, and take pride in each small victory you achieve. Remember, every line of code you write brings you one step closer to becoming a confident coder. So, let the journey begin! Happy coding, and may these exercises pave the way for an exciting and rewarding adventure in the fascinating world of programming! Let the coding escapades commence! Happy Coding! Belhadj Ahmed Rayane Hocine

CloudCSrest Beginner

1.Hello, World!: Start with the classic \"Hello, World!\" program. Print the phrase on the screen using Python. 2.Basic Calculator: Create a simple calculator that can perform basic arithmetic operations like addition, subtraction, multiplication, and division. 3.Guess the Number: Write a program where the computer generates a random number, and the user has to guess it. The program should give hints if the guess is too high or too low. 4.Even or Odd: Write a program that takes a user input and determines whether the number is even or odd. 5.Palindrome Checker: Create a program that checks if a word or phrase entered by the user is a palindrome (reads the same backward as forward). 6.Fibonacci Sequence: Write a program to generate the Fibonacci sequence up to a given number of terms. 7.Temperature Converter: Build a program that converts temperatures between Celsius and Fahrenheit. 8.List Manipulation: Practice working with lists by performing operations like sorting, reversing, finding the maximum/minimum, and removing duplicates. 9.Rock-Paper-Scissors Game: Develop a simple text-based game where the user plays against the computer. 10.File Handling: Create a program that reads and writes data to a file. For example, you can build a basic to- do list application.

11.FizzBuzz: Implement the FizzBuzz problem - print numbers from 1 to 100, but for multiples of 3 print \"Fizz,\" for multiples of 5 print \"Buzz,\" and for multiples of both 3 and 5, print \"FizzBuzz.\" 12.Password Generator: Write a program to generate a random password of a given length. 13.Prime Number Checker: Write a program to check if a given number is a prime number. 14.Shopping List Organizer: Build a simple program that allows the user to add, remove, and view items in a shopping list. 15.Tic-Tac-Toe Game: Design a text-based tic-tac-toe game that allows two players to play against each other. 16.Factorial Calculator: Create a program that calculates the factorial of a given number using a loop. 17.Greatest Common Divisor (GCD): Implement a program that finds the greatest common divisor (GCD) of two numbers using loops and conditional statements. 18.Palindrome Checker (with loops): Enhance the previous palindrome checker by using loops to check if a word or phrase is a palindrome. 18.Leap Year Finder: Write a program that prints the next 20 leap years. 19.Alternating Series Sum: Write a program that computes the sum of an alternating series where each element of the series is an expression of the form ((−1)^k+1)/(2^k−1) for each value of k from 1 to a million, multiplied by 4. Or, in more mathematical notation

20.List Maximizer: Write a function that returns the largest element in a list. 21.Checking List Elements: Write a function that checks whether an element occurs in a list. 22.Interlacing Lists: → Write a function that combines two lists by alternatingly taking elements, e.g. [a,b,c], [1,2,3] [a,1,b,2,c,3]. 23.Zigzag List Combiner: →Write a function that combines two lists by alternatingly taking elements, e.g. [a,b,c], [1,2,3] [a,1,b,2,c,3]. 24.On_all: Write a function on_all that applies a function to every element of a list. Use it to print the first twenty perfect squares. The perfect squares can be found by multiplying each natural number with itself. The first few perfect squares are 1*1= 1, 2*2=4, 3*3=9, 4*4=16. Twelve for example is not a perfect square because there is no natural number m so that m*m=12. (This question is tricky if your programming language makes it difficult to pass functions as arguments.) 25.Base Converter: Write a function that takes a list of numbers, a starting base b1 and a target base b2 and interprets the list as a number in base b1 and converts it into a number in base b2 (in the form of a list-of-digits). So for example [2,1,0] in base 3 gets converted to base 10 as [2,1]. 26.Rectangular Frame Printe: Write a function that takes a list of strings an prints them, one per line, in a rectangular frame. For example the list [\"Hello\", \"World\", \"in\", \"a\", \"frame\"] gets printed as: ********* *Hello * * World * * in * *a* * frame * *********

CloudCSrest intermediate

1.The 1-9 Number Puzzle: Write a program that outputs all possibilities to put + or - or nothing between the numbers 1,2,…,9 (in this order) such that the result is 100. For example 1 + 2 + 3 - 4 + 5 + 6 + 78 + 9 = 100. 2.Binary Search Tree: Implement a binary search tree data structure with insert, search, and delete operations. Test its functionality with different inputs. 3.Image Processing: Write a program that loads an image, applies a basic image filter (e.g., grayscale, blur, edge detection), and saves the filtered image. 4.Web Scraping: Use libraries like BeautifulSoup or Scrapy to scrape data from a website and store it in a structured format (e.g., CSV or JSON). 5.Graph Traversal: Implement depth-first search (DFS) and breadth-first search (BFS) algorithms to traverse a graph and find the path between two nodes. 6.Linked List Implementation: Implement a singly linked list data structure with operations to insert, delete, and traverse the list 7.Sorting Algorithm Implementation: Choose a sorting algorithm (e.g., Bubble Sort, Merge Sort, Quick Sort) and implement it from scratch. Test it with various input sizes and analyze its time complexity. 8.Morse Code Translator: Write a program that automatically converts English text to Morse code and vice versa. 9.Performance Comparison: Compare the performance of insertion, deletion and search on your unbalanced search tree with your balanced search tree and a sorted list. Think about good input sequences. If you implemented an (a,b)-tree, think about good values of a and b.

10.Unraveling List Interfaces: Think of a good interface for a list. What operations do you typically need? You might want to investigate the list interface in your language and in some other popular languages for inspiration. 11.Efficient Fibonacci Number Finder: Write a function that will find the nth number in the Fibonacci Sequence. 12.Reverse Words with Punctuation Intact: Write a function to reverse the order of words that have punctuation and keep the punctuation in place. 13.Defining a Class with Two Methods: Define a class which has at least two methods: getString: to get a string from console input printString: to print the string in upper case. Also please include simple test function to test the class methods. 14.2-D Array Generator: Write a program which takes 2 digits, X,Y as input and generates a 2-dimensional array. The element value in the i-th row and j-th column of the array should be i*j. Note: i=0,1.., X-1; j=0,1,¡­Y-1. 15.Text Capitalizer: Write a program that accepts sequence of lines as input and prints the lines after making all characters in the sentence capitalized. Suppose the following input is supplied to the program: Hello world Practice makes perfect Then, the output should be: HELLO WORLD PRACTICE MAKES PERFECT 16.Binary Divisibility Checker: Write a program which accepts a sequence of comma separated 4 digit binary numbers as its input and then check whether they are divisible by 5 or not. The numbers that are divisible by 5 are to be printed in a comma separated sequence. Example: 0100,0011,1010,1001 Then the output should be: 1010 Notes: Assume the data is input by console.

CloudCSrest Advanced

1.Finding the Longest Common Subsequence: Given two strings, write a program that efficiently finds the longest common subsequence. 2.AI Hangman Strategist: Write a program that plays Hangman as good as possible. For example you can use a large dictionary like this and select the letter that excludes most words that are still possible solutions. Try to make the program as efficient as possible, i.e. don’t scan the whole dictionary in every turn. 3.Battle Ship AI: Write a program that plays Battle Ship against human opponents. It takes coordinates as input and outputs whether that was a hit or not and its own shot’s coordinates. 4.Print Squares of Keys in a Dictionary: Define a function which can generate a dictionary where the keys are numbers between 1 and 20 (both included) and the values are square of keys. The function should just print the keys only. 5.Building a Canadian Class: Define a class named Canadaian and its subclass Torontonian. 6.Rectangle Class: Define a class named Rectangle which can be constructed by a length and width. The Rectangle class has a method which can compute the area. 7.Handling Division by Zero with try/except: Write a function to compute 5/0 and use try/except to catch the exceptions. 8.comma-separated numbers : write a program using generator to print the numbers which can be divisible by 5 and 7 between 0 and n in comma separated form while n is input by console. 9.Chinese Puzzle: Write a program to solve a classic ancient Chinese puzzle: We count 35 heads and 94 legs among the chickens and rabbits in a farm. How many rabbits and how many chickens do we have?.

10.Helloworld!: Please write a program which accepts a string from console and print the characters that have even indexes. Example: If the following string is given as input to the program: H1e2l3l4o5w6o7r8l9d Then, the output of the program should be: Helloworld 11.Gander Classes: Define a class Person and its two child classes: Male and Female. All classes have a method \"getGender\" which can print \"Male\" for Male class and \"Female\" for Female class. 12.Let's Play sport: Please write a program to generate all sentences where subject is in [\"I\", \"You\"] and verb is in [\"Play\", \"Love\"] and the object is in [\"Hockey\",\"Football\"]. 13.Dynamic programming: Solve a complex problem using dynamic programming techniques to optimize the time and space complexity of your solution. 14.Memory management: Implement a memory allocator to manage memory efficiently, avoiding fragmentation and optimizing allocations. 15. Scrape Script Write a Python script to scrape data from a website using BeautifulSoup or Scrapy. 16.Network server: Create a network server-client application to send and receive data between multiple machines using Python's socket module. 17.Comma Separated : Write a method that returns a comma-separated string based on a given list of integers. Each element should be preceded by the letter 'e' if the number is even, and preceded by the letter 'o' if the number is odd. For example, if the input list is (3,44), the output should be 'o3,e44'.


Like this book? You can publish your book online for free in a few minutes!
Create your own flipbook