473,609 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How does this code works?

2 New Member
Hi , I am beginner at python and programming. I have been doing some exercises about counting average from txt file.

txt file data is like this.

1 : 4.25
2 : 3.97
3 : 1.45
4 : 2.33


python code is like this.

name = []

for line in open("fileData. txt").readlines ():
name.append(lin e.strip().split (':')[1])

name = map(float,name)
avg = sum(name)/len(name)
print avg


Can anyone help me explaining in a simple way in this code ,

1.what does map in this code works?

2. name.append(lin e.strip().split (':')[1])
for this line , what I understand is data from txt file is inserted to the array.What does split(':') and [1] do?
May 8 '17 #1
0 1184

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1810
by: Razarr69 | last post by:
I have a ASP application that I am using for my company and it is currently running on a Windows 2000 server box with IIS 5. The code works perfectly there (except for handling large files - due to low amount of RAM, I hope anyway - thus the switch to the new server). Now I need to move the application to a better server. My hope was to just copy the folder to the new server and get running. This almost worked. :( The pages seem to...
4
5461
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) { document.getElementById(nameOfDiv).style.visibility='visible'; document.getElementById(nameOfDiv).style.height='auto'; if (nameOfDiv != 'weblogs')
1
1819
by: Avi | last post by:
Hi All. This code works very fine in Firefox but not in I.E. Can anybody help me out? it gives ... "Unknown Runtime Error" in I.E. This code ... Stores N*2 Matrix at Client Side & provide the mean to send the matrix to server side. =======================================================
21
2032
by: thomson | last post by:
Hi folks, Does any one have any idea which platform does GMAIL works, whether its JSP, ASPX or any other Regards thomson
6
2217
by: Crash | last post by:
C# VS 2003 ..Net Framework V1.1 SP1 SQL Server 2000 SP3 Enterprise Library June 2005 I'm working with some code {not of my creation} that performs the following sequence of actions: - Open SqlConnection using SQL authentication with UID & PWD in connect
4
2177
by: sgurminder | last post by:
Can anyone explain how this shell spawning code works...... I am not able to figure out exactly..... I got this from Aleph1's Smashing the stack file. :) Here it is ================================================================== testsc.c
11
1888
by: John | last post by:
Access 2003 After my app is finished I'd like to create an mde file. Therefore my db has to be made in the 2002-2003 format. So I've created a new mdb (default in 2000 format), I converted this empty mdb to the 2002-2003 format. I've started to add code but discovered that non of my VB code works. Even a simple <<msgbox "test">doesn't work. I constantly get the message about miscommunication between Access and OLE souce program or Active...
1
2164
by: reemamg | last post by:
Have a piece of code which works in Firefox however doesnt work in IE <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT="">
1
4741
by: Saad Alam | last post by:
Hi, I have added a link in my page that will make my site home page in users browser. <a class="makefeahome" onClick="this.style.behavior='url(#default#homepage)'; this.setHomePage('http://www.mySite.com');" >Home</a> This works fine IE but it does not works in FireFox. What should I do? Plz Help....
0
1429
by: kprawin | last post by:
Hi sir, Im new to Visual Basic, and I tried a simple application using VB2008 and MS-Access. It is a simple application to store Employee ID, Employee Name and Employee Photo. Both Employee ID and Name are of String type and Photo of OLE type in MS-Access database. I created the file employee.mdb and placed the file in MyProjects folder where my VB application is present. My Code Works, only if the .mdb file is located in the same location...
0
8129
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8220
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8404
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5509
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4017
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4080
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1386
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.