Category : function

I am trying to create a vignere cipher class that has the function to encrypt and decipher, vignere ciphers. However my code is returning the wrong characters and I was wondering if anyone could help me identify my problem. class Vignere(): def __init__(self): self.alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" self.enc_key = input("Please enter encription word: ") def vignere_encrypt(self, ..

Read more

I have a recursive function to which i pass certain args. The function is as below: def insert_category(root_id, parsed_category, parsed_id_name_map, id_pid_map, content_to_write): response_content = [] if content_to_write: response_content.extend(content_to_write) for _child in parsed_category: write_back_content = {} write_back_content = {"category_path": _child, "name": parsed_id_name_map[_child] ,"status" : "Successful" ,"err_desc" : "-" } form_category = {"pid": id_pid_map[root_id], "name": parsed_id_name_map[_child] } ..

Read more

Taking a Python dictionary called shop_items, and a single value called, target_item, as arguments. Example: shop_items = {‘Orange’:5, ‘Apple’:6, ‘Milk’: 1, ‘Towel’: 2} target_item = ‘Tomato’ Write a Python function, find_target(shop_item, targetItem), which return a True value if the target item exists in shop_items, otherwise returns a False Source: Python-3x..

Read more

This is the code that I am practicing with, it is supposed to print the number of tracks in the album but it does not show in the results. Can anybody please help me. def make_album(artist_name, album_title, album_tracks=0): music_album = {‘artist’: artist_name, ‘album title’: album_title} if album_tracks: music_album[‘tracks’]: album_tracks return music_album album = make_album(‘justin bieber’, ..

Read more

This is the code that I am practicing with, it is supposed to print the number of tracks in the album but it does not show in the results. def make_album(artist_name, album_title, album_tracks=0): music_album = {‘artist’: artist_name, ‘album title’: album_title} if album_tracks: music_album[‘tracks’]: album_tracks return music_album album = make_album(‘justin bieber’, ‘never say never’) print(album) album ..

Read more

Take a look at the example bellow: def add(a, b): return a + b def calc(c, d, fun): return fun(c, d) print(calc(1, 3, add)) The output is 4. I was using http://pythontutor.com to visualize what was happening during the execution of this code, and at some point, the arguments "1" and "3" where pointed out ..

Read more