Python Simple program

2014-01-18 Thread indar kumar
Hello, I am a newbie. Can somebody help me write the code for following program?


Write a program that takes student grades and prints out the GPA. The 
information is input, one student per line in the format:...
The number of students is not known in advance. You should prompt the user for 
more until they enter an empty line. The number of courses per student varies 
and is also not known in advance. You should read as many grades as are entered 
on the line.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Simple program

2014-01-18 Thread indar kumar
On Saturday, January 18, 2014 11:00:47 AM UTC-7, indar kumar wrote:
> Hello, I am a newbie. Can somebody help me write the code for following 
> program?
> 
> 
> 
> 
> 
> Write a program that takes student grades and prints out the GPA. The 
> information is input, one student per line in the format:  
>   ...
> 
> The number of students is not known in advance. You should prompt the user 
> for more until they enter an empty line. The number of courses per student 
> varies and is also not known in advance. You should read as many grades as 
> are entered on the line.



Hello, I think I just need one loop not separate loops. One while loop should 
be enough. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Can post a code but afraid of plagiarism

2014-01-18 Thread indar kumar
Hi,

I want to show a code for review but afraid of plagiarism issues. Kindly, 
suggest how can I post it for review here without masking it visible for public
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-18 Thread indar kumar
@Roy Smith

Can you help me privately because its an assignment and have to submit 
plagiarism free
-- 
https://mail.python.org/mailman/listinfo/python-list


Help with simple code that has database defined

2014-01-18 Thread indar kumar
I have to save students information in a database that is keeping continuously 
track of the information. Format is as follows:
Information:

Note: if this name already exists there in database, just update the 
information of that(name) e.g course,grade and date. Otherwise, add it.

What I think:

Database={}   #First Created a dictionary that will keep track
z = "Enter student name, course, grade and duration: "
line = raw_input(z)   
while (line != "quit"):
data = line.split()
name = data[0]
line = raw_input(z)   

This is just part because this is what I know how to do, for rest have no idea

The output should be like this:
{'alex': ['7', '8', '6'], 'john': ['9', '8', '7']})

Now as program will continuously prompt for input. If user enters “quit” it 
would exit. Otherwise it keeps taking input.

Now if there is already a name existing for example “alex” and his course, 
grade and duration are 7,8,6. Now in next turn of input if user again enters 
the name as alex but different entries for him e.g 9,9,9 so it should replace 
the older info by new e.g. it should replace 7,8,6 for alex by 9,9,9 and if 
user enters a entirely new name that is not in dictionary then it should be 
added to dictionary for example nancy 6 6 6 is the input then output should be:

{'alex': ['7', '8', '6'], 'john': ['9', '8', '7'],’nancy’:[‘6’,’6’,’6’]})


Kindly help.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-20 Thread indar kumar
Thanks all for help and positive comments. Actually, I tried to ask some 
questions but I was discouraged to do so saying that I was working on a project 
or some assignment. Truth be told I am stuck at one point and since I don't 
have experience with programming language, I have been working for it for two 
days but couldn't come up with some idea so posted some questions of the same 
format just to know whether there is particular method etc to do so. Hint would 
have been enough but I was strictly discouraged. You know the pain of working 
on assignment related to areas like socket programming and you even don't know 
how to use dictionaries and you are given only a week. Atleast I am trying to 
learn. The things that I am asking here are just basics on which my whole code 
would be building upon. But, as I said time is very less and have other courses 
also so wanted to know just the manipulation of dictionaries. 

If you allow me I can post a small part of that assignment, it just requires 
the manipulation with dictionary which I am not getting. I am not asking to 
write a code for me. But a small hint would get me out of trouble. 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-22 Thread indar kumar
So my question is if I am giving multiple inputs(a new device say for example) 
in a loop and creating a database(dictionary) for each new devices for example. 
I want subsequent devices to save their data(values only not keys) to the 
database of each of the already existing devices. How can I do that? Any hint?I 
have been stuck here for 3 days.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-22 Thread indar kumar
On Saturday, January 18, 2014 3:21:42 PM UTC-7, indar kumar wrote:
> Hi,
> 
> 
> 
> I want to show a code for review but afraid of plagiarism issues. Kindly, 
> suggest how can I post it for review here without masking it visible for 
> public

Pleae give example also. I will be thankful.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-22 Thread indar kumar
On Saturday, January 18, 2014 3:21:42 PM UTC-7, indar kumar wrote:
> Hi,
> 
> 
> 
> I want to show a code for review but afraid of plagiarism issues. Kindly, 
> suggest how can I post it for review here without masking it visible for 
> public

This is a gratuitous arp request
http://wiki.wireshark.org/Gratuitous_ARP
sent by PC1 is informing other hosts of its MAC and IP addresses.

Any hosts already in existence have their caches updated as needed.

The first config call has no other hosts to update, so all it does is create a 
dictionary entry with its host id as the key. Its cache table is created as an 
empty dictionary.

Subsequent config call update all other hosts' cache tables.


Each host has its own ARP cache table.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-22 Thread indar kumar
On Saturday, January 18, 2014 3:21:42 PM UTC-7, indar kumar wrote:
> Hi,
> 
> 
> 
> I want to show a code for review but afraid of plagiarism issues. Kindly, 
> suggest how can I post it for review here without masking it visible for 
> public

Description of each of the commands:
• config

◦ Parameters:
▪  is the host's ARP cache timeout, in seconds
◦ Actions:
▪ Update simulator's configuration database.
• If  already exists, its information should be updated. Otherwise, it 
should
be added.
▪ Print “ connected.”
▪ Have the host send a gratuitous ARP request .
• If any other hosts have an outdated entry for the MAC or IP address, they 
should
update their caches.
• If there are any responses to that request, that means that somebody else has 
this IP
address. If that is the case, you should print:
Error:  detected IP address conflict. It will be disconnected.
Then, you should “disconnect” the host from the simulated network, in order to
prevent further problems. You can implement this by removing it from the
configuration database.
◦ Note: any ARP packets generated by the command should be printed in the 
previously
specified format


Sample Output:

config
Please enter
PC1 01:01:01:01:01:01 192.168.0.1 200
PC1 connected.
ARP request 01:01:01:01:01:01 FF:FF:FF:FF:FF:FF 192.168.0.1 192.168.0.1
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-22 Thread indar kumar
On Saturday, January 18, 2014 3:21:42 PM UTC-7, indar kumar wrote:
> Hi,
> 
> 
> 
> I want to show a code for review but afraid of plagiarism issues. Kindly, 
> suggest how can I post it for review here without masking it visible for 
> public

Any link related to such type of problems or logic would be helpful
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-22 Thread indar kumar
On Saturday, January 18, 2014 3:21:42 PM UTC-7, indar kumar wrote:
> Hi,
> 
> 
> 
> I want to show a code for review but afraid of plagiarism issues. Kindly, 
> suggest how can I post it for review here without masking it visible for 
> public

I need to implement this with simple dictionarie. I know use of dictionaries, 
lists and tuples. But, I am not able to create a logic in a loop. I mean how 
the other hosts would get MAC and IP of subsequent hosts in each turn. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-22 Thread indar kumar
On Saturday, January 18, 2014 3:21:42 PM UTC-7, indar kumar wrote:
> Hi,
> 
> 
> 
> I want to show a code for review but afraid of plagiarism issues. Kindly, 
> suggest how can I post it for review here without masking it visible for 
> public

Just one hint and I have made the design for whole code. Just stuck at this part
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-22 Thread indar kumar
On Saturday, January 18, 2014 3:21:42 PM UTC-7, indar kumar wrote:
> Hi,
> 
> 
> 
> I want to show a code for review but afraid of plagiarism issues. Kindly, 
> suggest how can I post it for review here without masking it visible for 
> public

Thanks for kind help.

I have following nested dictionary

hosts={'PC2': ['02:02:02:02:02:02', '192.168.0.2', '200', {'192.168.0.2': 
('02:02:02:02:02:02', 1390461798.531)}], 'PC1': ['01:01:01:01:01:01', 
'192.168.0.1', '200', {'192.168.0.2': ('02:02:02:02:02:02', 1390461798.531), 
'192.168.0.1': ('01:01:01:01:01:01', 1390461787.78)}]}


How can I print a particular tuple from this table?


What I am trying to do is
input1=raw_input("Please enter id of host and IP that you want to be resolved")
z=input1.split()
print("PC3 resolved"+' '+z[1]+' to'+hosts[z[0]][3] z[1])

#z[1] is ip entered and [z[0]][3] z[1] is the particular location of value(MAC) 
associated with IP that I want to print.


But failed to do so. How can I print that. Please guide
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-23 Thread indar kumar
On Saturday, January 18, 2014 3:21:42 PM UTC-7, indar kumar wrote:
> Hi,
> 
> 
> 
> I want to show a code for review but afraid of plagiarism issues. Kindly, 
> suggest how can I post it for review here without masking it visible for 
> public

I just need to print first element of tuple not the whole
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-23 Thread indar kumar
On Saturday, January 18, 2014 3:21:42 PM UTC-7, indar kumar wrote:
> Hi,
> 
> 
> 
> I want to show a code for review but afraid of plagiarism issues. Kindly, 
> suggest how can I post it for review here without masking it visible for 
> public

Thank You 

I have found this forum very helping...GOD BLESS YOU ALL
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-23 Thread indar kumar
On Saturday, January 18, 2014 3:21:42 PM UTC-7, indar kumar wrote:
> Hi,
> 
> 
> 
> I want to show a code for review but afraid of plagiarism issues. Kindly, 
> suggest how can I post it for review here without masking it visible for 
> public

hosts={'PC2':['02:02:02:02:02:02', '192.168.0.2', '200', {'192.168.0.2': 
('02:02:02:02:02:02', 1390461798.531)}],'PC1':['01:01:01:01:01:01', 
'192.168.0.1', '200', {'192.168.0.2': ('02:02:02:02:02:02', 1390461798.531), 
'192.168.0.1': ('01:01:01:01:01:01', 1390461787.78)}]} 


Hi,
I want to print a value before a particular value inside of a list associated 
with a key inside main dictionary(hosts) not the one inside nested dictionary.

Forexample,
I want the user to input ip e.g. 192.168.0.2 and then search through dictionary 
print MAC e.g.02:02:02:02:02:02 that is just before that IP. Note that host 
id(e.g.PC2) is not known user just inputs IP. 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-23 Thread indar kumar
On Saturday, January 18, 2014 3:21:42 PM UTC-7, indar kumar wrote:
> Hi,
> 
> 
> 
> I want to show a code for review but afraid of plagiarism issues. Kindly, 
> suggest how can I post it for review here without masking it visible for 
> public

Just the value e.g.01:01:01:01:01:01 not the list 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-23 Thread indar kumar
On Saturday, January 18, 2014 3:21:42 PM UTC-7, indar kumar wrote:
> Hi,
> 
> 
> 
> I want to show a code for review but afraid of plagiarism issues. Kindly, 
> suggest how can I post it for review here without masking it visible for 
> public

Can I do the following to just get the value as string not the type list?

searchfor = '192.168.0.2'
z=[ii[0] for ii in hosts.values() if ii[1] == searchfor]
>>> str1 = ''.join(z)
>>> str1
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-23 Thread indar kumar
On Saturday, January 18, 2014 3:21:42 PM UTC-7, indar kumar wrote:
> Hi,
> 
> 
> 
> I want to show a code for review but afraid of plagiarism issues. Kindly, 
> suggest how can I post it for review here without masking it visible for 
> public

Thanks

config_database={'PC2': ['02:02:02:02:02:02', '192.168.0.2', '200'], 'PC3': 
['03:03:03:03:03:03', '192.168.0.3', '200'], 'PC1': ['01:01:01:01:01:01', 
'192.168.0.1', '200']}

What if I want to search for a particular value inside the lists of all keys 
except one that user inputs and also want to print that value.

Forexample, user gets prompt to enter following four parameters
prompt1= "Enter   "  

After user has input I have added this information into above 
dictionary(config_database) but I also need to check if this ip is not already 
assigned to a PC other than the one which user inputs. So how to search for 
particular value inside the lists associated with keys other than inside that 
one which user inputs(because obviously then it would match so just want to 
skip its own entry) and print that value.




-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-23 Thread indar kumar
On Saturday, January 18, 2014 3:21:42 PM UTC-7, indar kumar wrote:
> Hi,
> 
> 
> 
> I want to show a code for review but afraid of plagiarism issues. Kindly, 
> suggest how can I post it for review here without masking it visible for 
> public

Yes now I want to search for an ip that user has input but skipping the key 
which user has input. e.g. user entered PC1 and 192.168.0.1. Now I want to scan 
through config_database to see if this ip is already in it. But PC1 192.168.0.1 
is added to config_database before searching so I want to skip PC1 key during 
searching so that I can see if this Ip is not already associated with any other 
host.
-- 
https://mail.python.org/mailman/listinfo/python-list