Author: by Beh - dejavucode.com

September 23, 2023

Java Basics Exercises – Part 2

What does this code displays in the console? String relationshipStatus = “Single”; System.out.println(relationshipStatus); Single relationshipStatus Submit What is the output of this code? String color = “Blue”; //color = “Green”; System.out.println(color); Green Blue Submit What is the return value of this round() method? System.out.println(Math.round(12.49)); 12 13 Submit What is the return value of this length() […]

September 5, 2023

Python Exercises to Check Your Programming Knowledge

What is the output of the round() function? market_share = 12.03298 rounded_market_share = round(market_share, 2) print(rounded_market_share) 12.2 12.03 Submit Imagine you are developing a scheduling application that allows users to create events and manage their availability. You have two sets representing the available time slots for two different users: User A and User B. Each […]

September 3, 2023

Python Exception Handling Exercises

Why do we use exception handling ? To introduce intentional errors and bugs into the code for testing purposes To handle exceptional situations and prevent crashes Submit What is the output of this code? try: num = int(“$10”) print(num) except ValueError: print(“An exception occurred. Invalid conversion to an integer!”) $10 An exception occurred. Invalid conversion […]

September 3, 2023

Python Classes Exercises

Complete the class definition. ” Employee: def __init__(self, name, position, department): self.name = name self.position = position self.department = department Submit Add a new attribute to the class. class Employee: def __init__(self, name, position, department, salary): self.name = name self.position = position self.department = department ” salary self = salary == . Submit Create a […]

September 3, 2023

Python Sets Exercises

Which of the following options correctly identifies the keys and values in the dictionary? my_dictionary = {“cat”: “meow”, “dog”: “woof”, “bird”: “tweet”} Keys: cat, dog, bird Values: meow, woof, tweet Keys: meow, woof, tweet Values: cat, dog, bird Submit Imagine you are building a task management application. You have a dictionary representing a user’s tasks, […]