Jump to content

zak100

Senior Members
  • Posts

    233
  • Joined

  • Last visited

Everything posted by zak100

  1. Hi, I got some in complet program from a book "aipython": The code after some modification is: fun_list1 = [ ] for j in range(5): def fun1(e): return e + j fun_list1.append(fun1) for x in fun_list1: print(x) What I understand is that I have a for loop which is invokingthe function "fun1(e)" 5 times and the return value is stored in a list.I trying to print the list, I am getting following output: So I understand that I have to put this whole thing in a function and then pass some argument e to the function, and then it will work. Some body please guide how to execute this program such that I get some answer for the list. Zulfi.
  2. Hi, Thanks for the comprehensive answer. I would try to understand it. Zulfi.
  3. Hi, I have written the following Python program: 1.a= ["a", "f", "bar", "b","a", "aaaaa"] 2.ind = {a[i]:i for i in range(len(a))} 3.print(ind) 4.print("ind['a']= {0}".format(ind['a'])) 5.print("a[5]= {0}, a[4]= {1}, a[3]= {2}, a[2] = {3}, a[1] = {4}, a[0]= {5}".format(a[5],a[4], a[3], a[2], a[1], a[0])) output is: Line #1 , I can understand, we are creating an array of 6 elements, starting index is 0 and end index is 5. I can’t understand following things in line#2: a) what is the purpose of ‘ind’ variabel? b) What is the purpose of curly bracket in line#2 c)What is the purpose of colon in line#2 d) Which statements are under the impact of ‘for’ loop and how will we know that the scope of ‘for’ loop has ended? e) There are two enteries for ‘a’ in the array, why I am getting the index for “ind[‘a’] as 4. Somebody please guide me Zulfi.
  4. Hi, I am trying to understand the Water Jug Problem. It can be represented by a tree but I can't understand that representation. I have following questions about thee tree: 1. How we created the left and right part of the tree? 2. What is the number on the edges indicates? Zulfi.
  5. import numpy as np import pandas as pd df3 = pd.DataFrame([[0, 2, 3], [0, 4, 1], [10, 20, 30]], index=[4, 5, 6], columns=['A', 'B', 'C']) print(df3) df3.at[4, 'B'] Following is the output: Somebody please guide me, how can i print the value of last statement? I solved this problem: print(df3.at[4, 'B']) Zulfi.
  6. Hi, Your solution worked. Thanks a lot for your help. God blesses you. Zulfi.
  7. Hi, I am trying to execute the following code: df2 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), columns=['a', 'b', 'c']) df2 = pd.DataFrame(data=d, dtype=np.int8) print(df2) I am getting the following error message: Somebody please guide me. Zulfi.
  8. Hi, Thanks for your response. God blesses you. You mean col1 and col2 are the keys and 1,2 and 3, 4 are the values. Keys are used for searching. But here one key i.e. Col1 or Col2 is corresponding to 2 values. How will we resolve the searching problem? Zulfi.
  9. Hi, I am following the link at: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html The link says that Constructing DataFrame from a dictionary and then it shows the program: import pandas as pd d={'col1': [1, 2], 'col2':[3, 4]} df = pd.DataFrame(data = d) print (df) I got the following output: I can't understand the concept of dictionary here. Somebody please guide me with a more meaningful example. Zulfi.
  10. I am trying to understand the pandas package. I understand that it is 2d representation of data. I got the following program from the link: http://www.python-ds.com/python-pandas import pandas as pd prices=[ [71,72,73],[77,78,70],[79,72,73], [74,78,70],[71,88,73],[77,68,70], [71,72,73],[77,78,70],[79,72,73], [74,78,70],[71,88,73],[77,68,70] ] simple_dataframe=pd.DataFrame(prices) I can understand the above code. But I am having problem in understanding the following line: print("Simple Data Frame\n",simple_dataframe) header_dataframe=pd.DataFrame(prices,columns=['Jan','Feb','Mar']) I can’t understand the command pd.DataFrame(prices, columns = ['Jan','Feb','Mar']): It is giving the following output: What is the purpose of : prices, columns = [‘Jan’, ‘Feb’, ‘Mar’]) Why are we getting ‘)’ in the output? Somebody please guide me. Zulfi.
  11. Hi, Thanks, it worked. God bless you. Zulfi.
  12. Hi, I am trying to compile the following program: import numpy as np import sklearn.preprocessing from sklearn import preprocessing Input_data = np.array([2.1, -1.9, 5.5], [-1.5, 2.4, 3.5], [0.5, -7.9, 5.6], [5.9, 2.3, -5.8]) data_binarized = preprocessing.Binarizer(threshold = 0.5). transform(Input_data) print("\nBinarized data:\n", data_binarized) I am getting the following error: Traceback (most recent call last): File "/home/zulfi/PycharmProjects/AI/AI1.py", line 8, in <module> [5.9, 2.3, -5.8]) TypeError: array() takes from 1 to 2 positional arguments but 4 were given Process finished with exit code 1 Some body please guide me. Zulfi.
  13. Hi, I ran the following program on the answer set: p :- not q. r :- p. s:- r, not p. I executed the program on clingu (https://potassco.org/clingo/run/) I am getting the Answr set (AS) : {p, r} Why s is not in the answer set. Some body please guide me. Zulfi.
  14. Consider the following pseudo-WEP protocol. The key is 4 bits and the IV is 2 bits. The IV is appended to the end of the key when generating the keystream. Suppose that the shared secret key is 1010. The keystreams for the four possible inputs are as follows: 101000: 0010101101010101001011010100100 . . . 101001: 1010011011001010110100100101101 . . . 101010: 0001101000111100010100101001111 . . . 101011: 1111101010000000101010100010111 . . . Suppose all messages are 8 bits long. Suppose the ICV (integrity check) is 4 bits long, and is calculated by XOR-ing the first 4 bits of data with the last 4 bits of data. Suppose the pseudo-WEP packet consists of three fields: first the IV field, then the message field, and last the ICV field, with some of these fields encrypted. I found the following solution: a. We want to send the message m=10100000 using the IV=11 and using WEP. What will be the values in the three WEP fields? Since IV = 11, the key stream is 111110100000 ………. Given, m = 10100000 Hence, ICV = 1010 XOR 0000 = 1010 The three fields will be: IV: 11 Encrypted message: 10100000 XOR 11111010 = 01011010 Encrypted ICV: 1010 XOR 0000 = 1010 What is the purpose of the key stream? Somebody please guide me. Zulfi.
  15. Hi myfriend- Thanks a lot for your response. I got the code from the following link: https://github.com/Bdragon93/reentrancy-acttack Please check the above image, they have not defined 'c[0]'. My Truffle version: Kindly tell me which version are you talking about? Kindly guide me which tutorial are you using, what is in your 'test' file? Zulfi. Hi fiveworlds- You are right. It was a version problem. Correct: truffle(ganache)> const putAmount = putBalance.toNumber() undefined Zulfi.
  16. Hi, I am trying to run the following code. I am getting error while executing the line: truffle(ganache)> const putAmount = putBalance.c[0] The error is : I have uploaded the image of the whole program. I don't have much knowledge of Javascript. Somebody please guide me how to define the property 'c[0]'. Zulfi.
  17. Hi, I am trying to capture the SSL/TLS packets in the log file. I am following wiki's article but my SSLKeylogfile is empty. I am working in the ubuntu's (18.04) virtual machine. My wireshark version is 3.2.4. I am also attaching an image. Somebody please guide me what is my mistake? Zulfi.
  18. Hi, Thanks for your response. I don't know how can I make buyers satisfactions dependent. I am assuming that buyer's satisfaction depends upon price of the car, outlook of the car and engine of the car based upon the probability values. Please guide me how can I make buyer's satisfactions in a proper manner. I think I am not able to understand this concept properly. Please help me to improve this problem and also my solution in the context of MonteCarlo. Zulfi.
  19. Hi, I want to do capture SSL packet and then decrypt it using wireshark. I saw a video which captures the packets and it shows keyed packets in a video. I have provided a link for the video: I have also attached the image. I want to know how can I decrypt the packets using wireshark? Zulfi.
  20. Hi, I have installed 3.2.4 version of wireshark but in Edit-> Preference->Protocol I can't see the SSL protocol so I selected TLS. Now I can't see nstrace.sskeys in (pre) Master-Secret log filename. I am following the tutorial at: Decrypting SSL and TSL traffic Somebody please guide me is this file necessary for "decrypting SSL and TLS Traffic using wireshark" Zulfi.
  21. Hi, I have a question which I want to solve using MonteCarlo Method Suppose we have a car for sale and a buyer is 65% satisfied with the price of the car, 75% satisfied with the outlook of the car like its body, color, tires and 85% satisfied with the running i.e. the engine? What is the probability that the car would be sold to the said buyer? How we can do a simulation using Monte Carlo Method? I found the answer as: 0.65 * 0.75 * 0.85 = 0.4143 Is this a correct solution? Also please tell me can I use MoteCarlo method for one person? Zulfi.
  22. Hi All, Thanks for your response. First picture is mine. Second one which has the label "Network Analyzer belongs to the tutorial". I am using Ubuntu 18.04. Yesterday I closed it and open several after that I was able to see the correct ports and I was able to do capturing also but today I am seeing the same image as image 1. I have ether0 interface but it was showing me some thing en.. (i think 3 more letters after it). I am watching the videos. I would try some browsing. Zulfi. Hi thanks all, Ghideon your advise was good. I infact installed the wireshark yesterday but some how it was old. I did not check its version. Its on my virtual machine but today some how I installed the wireshark again and its a latest version. I am attaching its image. God blesses you all. Zulfi.
  23. Hi, I am seeing a tutorial, it shows me the interfaces which I have on my computer but wireshark is showing me different interfaces. I have attached the image of both the tutorial and what I am seeing on the wireshark. Somebody please guide me how to select the interfaces related to my computer and how to capture the packets Zulfi.
  24. Hi, I am trying to understand the following question: In a 3-bit block cipher, suppose a sender transmits a cipher text including c(1), r(1), c(2), r(2), c(3), r(3) to a receiver. Find the original plaintext at the receiver. Here c(1) = 100, r(1) = 001, c(2) = 010, r(2)= 111, c(3) = 000, and r(3) = 100. A block cipher encryption key table (Ks) is also shown below: The answer for the first case is: M(1) = Ks(c(1) XOR r(1) = Ks(100) XOR 001 = 010 From the table, the output corresponding to 100 to 011. But the above answer is 010. I can't understand this. Somebody please guide me. Zulfi.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.