V

@Videonerd03

List basics

Python
2 months ago
#Given the user inputs, complete a program that does the following tasks: #Define a list, my_list, containing the user inputs: my_flower1, my_flower2, and my_flower3 in the same order. #Define a list, your_list, containing the user inputs, your_flower1 and your_flower2, in the same order. #Define a list, our_list, by concatenating my_list and your_list. #Append the user input, their_flower, to the end of our_list. #Replace my_flower2 in our_list with their_flower. #Remove the first occurrence

Musical Note Frequencies

Python
2 months ago
# On a piano, a key has a frequency say f0. Each higher key has a frequency of f0 *r**n # where n is the distance (number of keys) from that key m and r is (1/12). # Given an initial key frquency, output that frequency and the next 3 higher key frequencies. #Output each floating-point value with two digits after the initial decimal point, then the units ("Hz"), then a newline, using the following statement: #print (f'{your_value:.2f} Hz') import math

Using math functions

Python
2 months ago
# given three floating-point numbers x, y, and z, output x to the power of z # to the power of (y to the power of z) # the absolute value of (x minus y) and square root of (x to the power of z) #Output each floating-point value with two digits after the decimal point, which can be achieved as follows: #print (f' {your_value1:.2f} {your_value2:.2f} {your_value3:.2f} {your_value4:.2f}') x = float(input())

Expression for calories burned during workout

Python
2 months ago
#Regular division = / (returns a float, even if its a whole number) # calories = (age * 0.757 + weight * 0.03295 + HeartRate * 1.0781 - 75.4991) * time / 8.368 #Write a program using inputs age(years), weight (pounds), heart rate(beats per minute), and time(minutes), respectively. # Output the average calories burned for a person #Output each floating-point value with two digits after the decimal point which can achieved as follows:

Divide input integers

Python
2 months ago
#Write a program that reads integers user_num and div_num as input, and outputs user_num divided by # div_num three times using floor divisions # Get the user input from the user user_num = int(input()) #Get the division number from the user div_num = int(input()) floor_division1 = user_num // div_num

Revise practice for python

Python
2 months ago
#Review Competency 1, Python Programming Elements and Syntax: #Review: #Chapter 2: Introduction to Python, #Chapter 3: Variables and Expressions, #Chapter 4: Types, #Chapter 8: Strings. #Complete all of Chapters 3, 4, and 8 ZyLab exercises at 100%. #Review Competency 2, Functions and Control Structures in Python: #Review: #Chapter 5: Branching,

Multiple exception handlers

Python
2 months ago
try: user_num = int(input()) div_num = int(input()) print(user_num// div_num) except ZeroDivisionError as e: print("Zero Division Exception: ", e) except ValueError as a: print("Input Exceptiopn:", a )

Car Wash

Python
2 months ago
# Write a progam to calculate the tota price for car wash services. # A base car wash is $10. A dictonary with each additional service and the corresponding cost has been provided. #Two additional services can be selected. A '-' signifies an addiional service was not selected. #Output all selected services, according to the input order, along with the corresponding costs and then the total price for all car wash services. # Ex if the input is:

Days converted to date

Python
2 months ago
def get_month_as_int(monthString): if monthString == 'January': month_int = 1 elif monthString == 'February': month_int = 2 elif monthString == 'March': month_int = 3 elif monthString == 'April': month_int = 4

Why a while loop is shown

Python
2 months ago
# Instead of a for loop # The problem statement says: # "Output the first integer and subsquent increments of 5 as long as the value is less than or equal to the second integer" # The lanaugage maps almost directly to a while loop: # start at a value # Keep going while a condition is true # Manually increase the value by 5 each time

Python Problem # 3 Index value for any of the seven elements

Python
2 months ago
#Create a solution that accepts an integer input representing the index value for any of the seven elements in the following list: #data_mixture = ["Python is fun", 2024, 5.67, ["apple", "banana", "coconut"], False, None,{"name": "John", "age": 25}] #The solution should perform the following: #Retrieve the element at the given index. #Determine its data type using the type() function and its .name attribute. #Check if the element belongs to one of the following categories: #if #If the eleme

Python Problem #2 number of ounces

Python
2 months ago
# Create a solution that accepts an integer input representing any number of ounces. Output the converted total number of tons, pounds # and remaining ounces based on the value of the input ounces. There are 16 ounces in a pound, and 2,000 pounds in a ton. #The solution output should be in the format: # Tons: value1 Pounds: value_2 Ounces: value_3 #Sample Input/ Output # If the input is 32,500 #Then the expected output is Tons: 1 Pounds 31 Ounces: 4

Python Problem #1 Times an employee travels to a jobsite in a month

Python
2 months ago
#Create a solution that accepts three integers input representing the number of times an employee travels to a jobsite in a month #Output the total distance traveled to two decimal places according to the miles each employee commutes to the jobsite: #Employee A: 15.62 miles #Employee B: 41.85 miles #Employee C: 32.67 miles # The solution output should be in the format: #distance_total_miles, traveled_miles

Introduction to Programming in python (PRACTICE)

Python
3 months ago
# A palindrome is a word or a phrase that is the same when read both forward and backward. Example are: "bob", "sees" or "never odd or even" (ignoring spaces) # Write a program whose input is a word or phrase and that outputs whether the input is a plaindrome # Ex: If the input is: bob # The output is: palindrome: bob #Ex: If the input is: bobby # The output is not a palindrome: bobby #Hint: Start by removing spaces. Then check if the string equals itself in reverse

Food item

Python
3 months ago
# complete the fooditem class by adding a constructor to initalize a food item. The constructor should initailize the name (a string) # To water and all other instance attributes to 0.0 by default #If the constructor is called with a food name, grams of fat, grams of carbohydrates and grams of protein, the constructor should assign each instance # attribute with the appropriate parameter value. class FoodItem: #Constructor with defaults def__init__(self, name="Water", fat=0.0, ca

Cars information

Python
3 months ago
class Car: def__init__(self): # self defines a specific object that calls the method # Attributes that belong to the object are stored on self self.model_year = 0 self.purchase_price = 0 self.current_value = 0 def calc_current_value(self, current_year): depreciation_rate = 0.15

output art

Python
3 months ago
user_shape = input() if user_shape == "square": print("***\n* *\n***") elif user_shape == "triangle": print(" *\n * *\n*****")

dragon fire

Python
3 months ago
import time import sys import os # Optional: enable ANSI colors on newer windows terminals if os.name == 'nt': os.system("") #Enables ANSI escape sequences in Windows 10+ consoles def countdown(seconds: int = 30): """ Simple countdown with a progress bar"""

Expression Test scores

Python
3 months ago
# Given your current grade as the input, write a program to help you determine what score you need to get on a final to get an A (90% or higher) in a class # The syllabus states that the final is worth 40% of the overall # The input is an integer # The output should be a percentage rounded to one decimal place # What we are defining for this code # Current Grade, Current points, points needed to get to 90%, and the grade on the final currentGrade = int(input())

Phone number

Python
3 months ago
# solution to accept a 9-digit integer representing an unformatted student identification number #Solution outputs formatted student identification number as a string # this practice gives you a way to show you how to put in the first digit in the code print("Enter Student Identification Number:") phone_number = int(input())