Language is Python 3.6 Function name: translaton Parameters;: a filename (str),
ID: 3599839 • Letter: L
Question
Language is Python 3.6
Function name: translaton Parameters;: a filename (str), a string Returns: a string Description: Write a function that takes in a filename and a string, then uses the file to create a dictionary with English words as the keys and the corresponding words in another language as the values. In the string passed in, replace every word that is a key in the dictionary with the value that the key maps to and return that new string. NOTE: You can assume the file passed in will always be in the format specified in the test cases below, and that the string will be all owercase Test cases: french dictionary.txt hello, bonjour my, morn name, nom is, est >> translator("french_dictionary.txt", "hello, my name is christine! my favorite food is pizza.") bonjour, mon nom est chresttine! mon favorite food est pizza Authors: Christine Feng and Rodrigo Meja CS1301 -HOMEWORK 07: INTRO TO DICTIONARIES 4 erman dictionary.txt i, ich read, lebe many, viele books, Bucher study, studiere math, Mathematik and, und >>>translator("german_dictionary.txt", "i read many books. i study math and computer science.") ich lebe viele Bucher. ich studiere Mathematik und computer scichence."Explanation / Answer
package com;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.ArrayList;
import java.util.Random;
import javax.swing.JPanel;
public class Graph extends JPanel {
public Graph() {
setSize(500, 500);
}
@Override
public void paintComponent(Graphics g) {
Graphics2D gr = (Graphics2D) g; // This is if you want to use Graphics2D
// Now do the drawing here
ArrayList<Integer> scores = new ArrayList<Integer>(10);
Random r = new Random();
for (int i : scores) {
i = r.nextInt(20);
System.out.println(r);
}
int y1;
int y2;
for (int i = 0; i < scores.size() - 1; i++) {
y1 = (scores.get(i)) * 10;
y2 = (scores.get(i + 1)) * 10;
gr.drawLine(i * 10, y1, (i + 1) * 10, y2);
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.