C

@cheeseofthecheeses

class parrot

Python
1 day ago
class Parrot: speices = "bird" def __init__(self, name , age): self.name = name self.age = age

oriented

Python
1 day ago
class Vehicle: def __init__(self, max_speed, mileage): self.max_speed = max_speed self.mileage = mileage

test 3 HW

Python
1 day ago
import random import string def generate_password(length): lowercase = string.ascii_lowercase uppercase = string.ascii_uppercase characters = lowercase + uppercase password = [] password.append(random.choice(lowercase)) passw

list comprehension

Python
1 day ago
students = [{'name': 'Alice', 'grade': 85}, {'name': 'Bob', 'grade': 92}, {'name': 'Charlie', 'grade': 78}] high_performers = [student['name'] for student in students student['grade'] >= 85] grade_categories = [(student['name'], 'Pass') if s['grade

test 3

Python
5 days ago
grade_book = {"Alice": 85, "Bob": 92, "Charlie": 78, "Arindam": 95, "Asad": 88} total = 0 for s in grade_book.Values(): total += s print(f"Average: {total/len(grade_book):.2f}") best = max(grade_book,key=grade_book.get) worst = min(grade_book,k

zip it.py

Python
1 week ago
s1 = {2, 3, 1} s2 = {'b', 'a', 'c'} s3 = list(zip(s1,s2)) print(s3)

hands on map.py

Python
1 week ago
nums = [1 ,2 ,3 ,4 ,5 ] def square(number): return number * number square = list(map(square, nums)) print("square of numbers in list") print(square)

hands on map.py

Python
1 week ago
nums = [1 ,2 ,3 ,4 ,5 ] def square(number): return number * number square = list(map(square, nums)) print("square of numbers in list") print(square)

sats and arrey

Python
1 week ago
# Define two sets set1 = {1, 2, 3, 4, 5} set2 = {4, 5, 6, 7, 8} # Find symmetric difference using symmetric_difference() method symmetric_diff = set1.symmetric_difference(set2) print("Set 1:", set1) print("Set 2:", set2) print("Symmetric Differenc

arrays

Python
1 week ago
import array as arr numberarray = arr.array('i', [1 ,3 ,5 ,3 ,7 ,9 ,3 ]) print("Original array is: " + str(numberarray))

operation on set

Python
1 week ago
my_set = (1.0 , "Hello" ,( 1, 2, 3)) print(my_set) my_set = {1, 2, 3, 4, 3, 2} print(my_set) my_set = set([1,2,3,4]) print = (my_set,"\n") num_set = set([0 ,1 ,3 ,4 ,5 ])

frequency

Python
1 week ago
def check_frequency(test_dict, target_value): """ Count frequency of a specific value in a dictionary """ count = 0 for value in test_dict.values(): if value == target_value: count += 1 return count test_d

tuples

Python
1 week ago
def product_of_tuple(tuple_data): "" Calculate the product of all elements in a tuple "" product = 1 for num in tuple_data: product *= num return product my_tuple = (2, 3, 4, 5) result = product_of_tuple(my_tuple)

test dictiomary

Python
2 weeks ago
test_dictionary = { 'codingal' : 2, 'is' : 2, 'best' : 2, 'for' : 2, 'coding' : 1 }

tuple operation py

Python
2 weeks ago
tuplex = ("tuple",False ,3.2 , 1) print(tuplex) numbericaltuplex = (4, 6, 2, 8, 3, 1) newtuplex = numbericaltuplex + (9,) print(newtuplex) tuple1 = (50, 10, 60, 70, 50) print(tuple1.count(50))

square values

Python
2 weeks ago
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] squares = [num ** 2 for num in numbers] print("Square values:") for i, sq in enumerate(squares): print(f"{numbers[i]} squared = {sq}") print(f"\nSum of squares: {sum(squares)}") print(f"Total num

month

Python
2 weeks ago
import calendar months = list(calendar.month_name)[1:] print("\n" + "=" * 40) print(" MONTHS OF THE YEAR") print("=" * 40) for i, month in enumerate(months, start=1): print(f" {i:2d}. {month}") print("-" * 40) print("\nAll months:")

idk waht to name'

Python
2 weeks ago
def match_words(words): item = 0 list = [] for word in words: if len(word) > 1 and word[0] == word[-1]: item = item + 1 list.append(word) print(list) return item

idk waht to name'

Python
2 weeks ago
def match_words(words): item = 0 list = [] for word in words: if len(word) > 1 and word[0] == word[-1]: item = item + 1 mylist.append(word) print(mylist) return item

Lists

Python
2 weeks ago
numbers = [1, 2, 3, 4, 5] print(numbers) aList = [100, 200, 300, 400, 500] aList = aList[::-1] print(aList)