This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from replit import clear | |
from art import logo, vs | |
from game_data import data | |
#get random information from data script | |
def get_data(): | |
''' | |
Gets a random dictionary entry from the game_data file and returns it | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Problem Description | |
The program takes two strings and checks common letters in both the strings. | |
Problem Solution | |
1. Enter two input strings and store it in separate variables. | |
2. Convert both of the strings into sets and find the common letters between both the sets. | |
3. Store the common letters in a list. | |
4. Use a for loop to print the letters of the list. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Problem Description | |
The program takes a string and creates a dictionary with key as first character and value as words starting with that character. | |
Problem Solution | |
1. Enter a string and store it in a variable. | |
2. Initialize a count variable to 0. | |
3. Create a set containing vowels. | |
4. Use a for loop to traverse through the letters in the string. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Problem Description | |
The program takes a string and creates a dictionary with key as first character and value as words starting with that character. | |
1. Enter a string and store it in a variable. | |
2. Declare an empty dictionary. | |
3. Split the string into words and store it in a list. | |
4. Using a for loop and if statement check if the word already present as a key in the dictionary. | |
5. If it is not present, initialize the letter of the word as the key and the word as the value and append it to a sublist created in the list. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Problem Description | |
The program takes a string and counts the frequency of words appearing in that string using a dictionary. | |
Problem Solution | |
1. Enter a string and store it in a variable. | |
2. Declare a list variable and initialize it to an empty list. | |
3. Split the string into words and store it in the list. | |
4. Count the frequency of each word and store it in another list. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Problem Description | |
The program takes two lists and maps two lists into a dictionary. | |
Problem Solution | |
1. Declare two empty lists and initialize them to an empty list. | |
3. Consider a for loop to accept values for the two lists. | |
4. Take the number of elements in the list and store it in a variable. | |
5. Accept the values into the list using another for loop and insert into the list. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Problem Description | |
The program takes a dictionary and removes a given key from the dictionary. | |
Problem Solution | |
1. Declare and initialize a dictionary to have some key-value pairs. | |
2. Take a key from the user and store it in a variable. | |
3. Using an if statement and the in operator, check if the key is present in the dictionary. | |
4. If it is present, delete the key-value pair. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Problem Description | |
The program takes a dictionary and multiplies all the items in the dictionary. | |
Problem Solution | |
1. Declare and initialize a dictionary to have some key-value pairs. | |
2. Initialize a variable that should contain the total multiplied value to 1. | |
3. Use the for loop to traverse through the values of the dictionary. | |
4. Then multiply all the values in the dictionary against each other. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Problem Description | |
The program takes a dictionary and prints the sum of all the items in the dictionary. | |
Problem Solution | |
1. Declare and initialize a dictionary to have some key-value pairs. | |
2. Find the sum of all the values in the dictionary. | |
3. Print the total sum. | |
4. Exit. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Problem Description | |
The program takes a number from the user and generates a dictionary that contains numbers (between 1 and n) in the form (x,x*x). | |
Problem Solution | |
1. Take a number from the user and store it in a separate variable. | |
2. Declare a dictionary and using dictionary comprehension initialize it to values keeping the number between 1 to n as the key and the square of the number as their values. | |
3. Print the final dictionary. | |
4. Exit. |
NewerOlder