我想把这个(总和)作为python中的列表形式

时间:2017-09-25 04:11:22

标签: python

success: function (data) { if (data.length > 0) { var Total = 0; var TotalCycle = 0; var oldValue = data[data.length - 1].WW, c = 1; for (var i = data.length - 1; i >= 0; i--) { let $tr = $('<tr/>'); if (i == 0 || oldValue != data[i - 1].WW) { $tr.append("<td rowspan=\"" + c + "\">" + "WW - " + data[i].WW + "</td>"); c = 1; if (i > 0) oldValue = data[i - 1].WW; } else { c++; } $tr.append("<td>" + data[i].Project + "</td>"); $tr.append("<td>" + data[i].OS + "</td>"); $tr.append("<td>" + data[i].TotalTests + "</td>"); Total = Total + data[i].TotalTests; $tr.append("<td>" + data[i].CycleRun + "</td>"); TotalCycle = TotalCycle+ data[i].CycleRun; $('#GraphTable').prepend($tr); } }

我想看看有多少学生得分超过60

4 个答案:

答案 0 :(得分:2)

你可以这样做:

// using SendGrid's C# Library
// https://github.com/sendgrid/sendgrid-csharp
using SendGrid;
using SendGrid.Helpers.Mail;
using System;
using System.Threading.Tasks;
using System.Threading;

namespace Example
{
    internal class Example
    {
        private static async Task Main()
        {
            await Execute();
            Thread.Sleep(10000);
        }

        static async Task Execute()
        {
            var apiKey = "myapikey";
            var client = new SendGridClient(apiKey);
            var from = new EmailAddress("test@example.com", "Example User");
            var subject = "Sending with SendGrid is Fun";
            var to = new EmailAddress("test@example.com", "Example User");
            var plainTextContent = "and easy to do anywhere, even with C#";
            var htmlContent = "<strong>and easy to do anywhere, even with C#</strong>";
            var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
            var response = await client.SendEmailAsync(msg);
        }
    }
}

答案 1 :(得分:1)

超过60分多少分?

>>> marks = [90, 25, 67, 45, 80]
>>> len([score for score in marks if score > 60])
3

这使用列表推导来创建一个新列表,其中仅包含那些超过60的分数,然后新列表的长度告诉您有超过60的分数。

另一种常见方法是使用sum()

>>> sum(1 if score > 60 else 0 for score in marks)
3

你也可以利用布尔值得注意的事实:

>>> sum(score > 60 for score in marks)
3

或者,为了更好地理解你,使用for循环:

count = 0

for score in marks:
    if score > 60:
        count += 1

print count

答案 2 :(得分:1)

我希望这个也有帮助。

这里我们使用filter函数来获取大于或等于60的元素,然后使用len函数得到no。元素。

Try this code snippet here

marks = [90, 25, 67, 45, 80]
print(len(filter(lambda x: x>=60,marks)))

答案 3 :(得分:1)

您可以使用filter仅包含您关注的标记:

marks = [90, 25, 67, 45, 80]
print(len(filter(lambda x: x>=60, marks)))