Win a book on IronPython or F#

Here is a little contest that will run for 14 days (until the 29-09-2009), where every developer should have a chance of winning!

The Contest has ended, and the winner was Yoni Holman! Congratulations!

I?ve created 7 questions, in different programming languages such as C#, F#, Ironpython, C++, Java and off course the well known and liked true or false. The questions are designed to give a number of points, where the maximum number of points given can be read in the text of the assignment. The rules are simple, the one with the highest score on points, will win. Points will be given for correctness and effort. An assignment might give 6 point, but if not entirely correct, it will be given some points for effort.

What can you win?

The winner gets Office 2007 Student version, and gets to choose one of two books ? Foundation of F# or IronPython in Action - and the runner-up gets the book that the winner did not choose.

FSharp ironpythoninaction OFF2007STUKEY

What to do now?

If you want to try out for the books, all you have to do is:

  • Leave a comment on this blog-post (in case that when you submit, and your assignment gets in my spam-mail-box, I?ll know to look for it here if its not in my usual mailbox.
  • Submit your answers (as a txt file) to my mail address (ajp at clug.dk)
  • Everyone is allowed to solve all the questions (if you can), or just some of them.
  • When mailing me, please leave ? if you have ? your Twitter name, and I will also post the winner and runner-up on twitter (if the winner and runner-up has a Twitter name).

Here are the questions

Question number 1.

6 point

The following code compiles and runs without problems, but everything is not as it should be. When a user enters the input as shown below, what is the output? And more important, why is the output as it is?

#include <iostream>

using namespace std;

char string1[2]; char string2[2]; char string3[7]; char string4[7];  char string5[8];

int main (){
    cout<< "\n Read 1. text (length 2)";
    cin>> string1;
    cout<< "\n Read 2. text (length 2)";
    cin>> string2;
    cout<< "\n Read 3. text (length 7)";
    cin>> string3;
    cout<< "\n Read 4. text (length 7)";
    cin>> string4;
    cout<< "\n Read 5. text (length 8)";
    cin>> string5;
    cout << "\n 1.: "<< string1;
    cout << "\n 2.: "<< string2;
    cout << "\n 3.: "<< string3;
    cout << "\n 4.: "<< string4;
    cout << "\n 5.: "<< string5;
    return 0;
}

Read 1. text (length 2) - F#
Read 2. text (length 2) - C#
Read 3. text (length 7) - ASP.NET
Read 4. text (length 7) - IronRuby
Read 5. text (length 8) ? IronPython

Answer:

1. F#C#ASP.NETIronRubIronPython
2. C#ASP.NETIronRubIronPython
3. ASP.NETIronRubIronPython
4. IronRubIronPython
5. IronPython

In C++ the strings are null terminated. This means that space must be preserved for null termination character. In the assignment above, the null character is overwritten, and therefor the output is as shown.

This example does have some issues regarding compiler dependencies, and yes this was also part of the assignment ;-)

Question number 2.

9 point.

The following is an application made with the .NET Micro Framework, but the code is missing two lines! The missing parts are an Output port, and an Input port. Implement these two line to complete the code.

using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

namespace MicroFramework
{
   public class Light
   {
     public static void Main()
     {
       Cpu.Pin pin = Cpu.Pin.GPIO_Pin1;
       Cpu.Pin switch = Cpu.Pin.GPIO_Pin2;
       //missing line
       //missing line

       while (true)
       {
         YourOutputPort.Write(YourInputPort.Read());
       }
      }
     }
}

Answer:

OutputPort YourOutputPort = new OutputPort(pin, false);
InputPort YourInputPort = new InputPort(switch, false);

Question number 3.

3 point.

The following code is F#, and it represents an array. Finish the code, so that every item in the array is printed out to the screen.

#light
let colors = [| "Blue"; "Green"; "Yellow"; "Black"; "White"; "Red"; |]

//iterate over the array, and print out the items within the array.

Answer (There are multiple ways of doing this) :

for color in colors do
    print_endline color

Question number 4.

4 point.

The following code is an array written in C#. create a LINQ query that selects the items that are less than 15 and do this:

  1. Using standard LINQ query
  2. Without the use of keyword "var" (without implicit typing).

int[] numbers = {5, 2, 10, 12, 16, 35, 20, 100};

//Create query

//iterate and print out items

Answer:

1.
var query = from i in numbers where i < 15 select i;

foreach(var i in query)
  Console.WriteLine("Number: {0}", i);

2.  
IEnumerable<int> query = from i in numbers where i < 15 select i;
foreach(int i in query)
  Console.WriteLine("Number: {0}", i);

Question number 5.

6 point.

Implement a function in IronPython that takes one parameter, and calculates and returns the Fibonacci series. Then call your function with the number 200.
shown here in pseudocode:

FibonacciFunction(aNumber)

calculate fibonacci

return number

call function
print output

Answer:

def fibonacci(number):
        result = []
        a, b = 0, 1
        while b < number:
             result.append(b)
             a, b = b, a+b
        return result

fib = fibonacci(200)   
fib

Question number 6.

8 point.

The following code is in Java, and it is a sorting algorithm. Two lines are missing, and you are to implement the missing lines.

public class HeapSort
{

    public void heapSort (int [] A)
    {
        printArray(A);
        makeHeap(A);
        printArray(A);
        for (int i = A.length-1;i >0 ;i--)
        {           
            int temp =0;
            temp = A[i];
            //Line missing
            A[0] = temp;
            reheap(A,0, i-1);
            printArray(A);
        }
    }
    public void makeHeap(int [] A)
    {
        for (int j = ((A.length / 2)-1);j>=0;j--)
        {
            reheap(A, j, A.length-1);
        }
    }
    public void reheap(int [] A, int current, int last)
    {
        int leftChild = 2* current +1;
        int rightChild = 2* current +2;
        int largest;
        int tempA=0;
        if (leftChild <= last && A[leftChild] > A[current])
        {
            largest = leftChild;
        }
        else
        {
            //Line missing
        }
        if (rightChild <= last && A[rightChild] > A[largest])
        {
            largest = rightChild;
        }
        if (largest != current)
        {
            tempA = A[current];
            A[current] = A[largest];
            A[largest] = tempA;
            reheap (A , largest, last);
        }
    }
    public void printArray(int [] A)
    {
        System.out.print("Array: ");
        for (int i = 0; i < A.length ; i++)
        {
            System.out.print( A[i] + ", ");
        }
        System.out.println("\n");
    }
    public static void main(String[] args)
    {
        int A [] = {10,23,75,24,98,87,27,11,34,28,17,13,31,37};
        HeapSort heap = new HeapSort();
        heap.heapSort(A);

    }

}

Answer:

A[i] = A[0];
largest = current;

Question 7.

Each correct answer will give 1 point each. (max point is 21).

In this assignment you should answer "true" or "false" to the following questions:

  1. IronPython is the .NET version of Python.
  2. IronPython is a functional programming language.
  3. There is nothing called IronRuby from Microsoft.
  4. IronPython does not work in a web browser.
  5. IronPython is a dynamic programming language.
  6. IronPython can interact with the C# programming language.
  7. IronPython is an OpenSource language.
  8. F# is a dynamic programming language.
  9. F# does not work with WPF (Windows Presentation Foundation).
  10. F# only works with math and formulas.
  11. F# works with Windows Forms.
  12. F# only runs on Windows Computers.
  13. F# is an OpenSource language.
  14. C# is the only programming language in .NET family.
  15. C# can only be used on Windows computers.
  16. The .NET MicroFramework is used for embedded systems.
  17. ASP.NET is a Java version of PHP.
  18. ASP.NET can only be used on Windows computers.
  19. ASP.NET, C#, F# and Silverlight all run on Linux.
  20. Moonlight on Linux is the same as C# on Windows.
  21. Mono is the same as F# on Windows.
Answer:

1. true
2. false
3. false
4. false
5. true
6. true
7. true
8. true
9. false
10. false
11. true
12. false
13. true
14. false
15. false
16. true
17. false
18. false
19. true
20. false
21. false

The text in small print

Everyone from every country is allowed to participate in this contest. The winner and runner-up will be notified by me personally, and I will personally send the books to their home address. If the winner and runner-up will allow it, their names will be posted on this website after I have talked to them.

All I can say now is good luck, and I hope you find this fun :-)

Currently rated 3.0 by 2 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: AllanJP
Posted on: 9/15/2009 at 6:48 AM
Categories: C# | IronPython | Programming | F# | Contest
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (8) | Post RSSRSS comment feed

IronPython

 

I had the pleasure of attending Harry Piersons TechTalk at Microsoft Development Center Copenhagen (MDCC) on IronPython.

IronPython is a new member of the .NET family, based on the programming language Python. The Iron part has become known as It-Runs-On-.NET.

IronPython is a dynamic programming language (as Perl, PHP, Ruby and JavaScript - Although Perl and PHP never truly was Object oriented at heart, but they are moving in that direction now), which means that execution happens at runtime and not at compiletime. Dynamic languages make it easy to quickly manipulate data, which often is collected from networks, user interfaces and devices, and are extremely powerful when it comes to manipulating meta-data, whereas static languages (eg. C#, C++, and Java) often prove its strengths in creating complex data structures and algorithms and so on. It’s said that Dynamic languages focus on the code, rather than the structure or “architecture”.

With IronPython in the .NET family the developers now have a perfect opportunity to combine the forces of static languages as C# with a dynamic language namely IronPython.

In Harry Piersons own words “Dynamic languages are easier to learn and therefore teach”. And then he gave a small example where he compared a “Hello World” program from C# with the same in IronPython:

// C# version of "Hello World"
class Program
{
static void Main()
{
System.Console.WriteLine("Hello, World");
}
}


// IronPython version of "Hello World"
print "Hello, World"

Now wait a second! What about C# 4.0?

C# version 4.0 now comes with a new keyword called “dynamic” which can be used to dynamically invoke methods, but I’ll let it be up to the reader to dig in deeper with the new version of C# coming out.

Is IronPython opensource?

YES it is! Microsoft has two licenses that have been approved by the Open Source Initiative(OSI), which means that developers can be confident that the licenses meet the terms of the Open Source Definition. And yes, the IronPython team is taking in contributions from the community, and for that – Microsoft I salute you. Thank you for showing initiative to promote things via opensource.

The roadmap for the IronPython project is, that in December 2008 it was shipped in version 2.0, and Microsoft hopes to release version 2.6 (Microsoft has decided to end confusions, and name the versions after Python release conventions ) in the near future. They are also planning to release IronPython for .NET version 4.0, (with release shortly after version 4.0), which will work with C# Dynamics and be compatible with Python version 2.6 and 3.1. The intention is not to have a release cycle like the one on Visual Studio, but rather have it be a plug-in for Visual Studio, so that the IronPython team can maintain a release cycle of ca. 10 months.

For more resources:

 

 


Just an update! You can view the video, and download the slides from the Tech Talk on Channel 9

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: AllanJP
Posted on: 9/14/2009 at 4:42 AM
Tags: ,
Categories: IronPython
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Tech ED 2009 in Berlin

The time has come, this November 9 -13 there will be Tech ED in Berlin.

The Tech ED is a really great place to get in- deep coverage of technical material from Microsoft,
but that's the only thing! You will have the ability to certified on the spot! And Microsoft Partner solutions
will also be presented.... Cool!

I've taken a snapshot to show which Topics will be presented at Tech ED 2009 Berlin:

 

273

The Windows Client track e.g. contains sessions on adoption, deployment, management,
and virtualisation of the Windows® Desktop Environment, including a technical introduction 
into Windows® 7 and Windows® Internet Explorer® 8.


The Web and Internet Application track contains sessions on Microsoft® Expression® Studio, Microsoft® 
Silverlight™, Microsoft® Internet Information Services (IIS), ASP.NET, ASP.NET AJAX,
Windows® Internet Explorer®, Windows Live™ Platform and more.

So as you can see it's an action packed Tech ED, covering the whole week:

 

And you can spend hours on their website just planning what to see!


For more information go to The TechED 2009 Berlin Website

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: AllanJP
Posted on: 9/1/2009 at 3:50 AM
Tags:
Categories: Tech ED
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed