Answer:
- To get the items of a dictionary and print them as a string, use the items() method to unpack the keys and values in a for and print or write them into a file.
for key, value in mydict.items():
print(f"{key}, {value}")
- To convert string from user input into dictionary;
mystring = input().split(" ") #assuming the words are separated by a space.
from word in mystring:
mydict[word] = mydict.get(word, 0) + 1
This would use the words in the string as the keys of the dictionary and the count of each word as the respective values.
Explanation:
A dictionary is a data structure in python used to store data in key-value pairs. The items are enclosed in curly braces and can be accessed with the key in dot or bracket notation.
Answer:
B. R is NP Hard
Explanation:
Given:
S is an NP complete problem
Q is not known to be in NP
R is not known to be in NP
Q is polynomial times reducible to S
S is polynomial times reducible to R
Solution:
NP complete problem has to be in both NP and NP-hard. A problem is NP hard if all problems in NP are polynomial time reducible to it.
Option B is correct because as given in the question S is an NP complete problem and S is polynomial times reducible to R.
Option A is not correct because R is not known to be in NP
Option C is not correct because Q is also not known to be in NP
Option D is not correct because Q because no NP-complete problem is polynomial time reducible to Q.
Answer:
Operating System
Explanation:
Master controller for all activities that take place within a computer; primary purpose is to help the computer system monitor itself in order to function efficiently
Answer:
(a)
Assuming the one-time pad P is used to XOR the message M to get ciphertext C, the following holds:
M ⊕ P = C
P = C ⊕ M
this is a basic property of how XOR works.
(b)
P = M1 ⊕ C1
then M2 = C2 ⊕ P
(c)
The attacker can make assumptions about the message (e.g., presence of certain words and spaces) and then calculate which pad would be needed to get them in the ciphertexts. He then has two ciphertexts that should yield valid content, making it much more easy to guess the pad.
Explanation: