Thanks,

In my same program i am trying to display the result on a second form, but i am having problem getting it done. can someone please point me to the right direction.

Thanks,

Thanks,

In my same program i am trying to display the result on a second form, but i am having problem getting it done. can someone please point me to the right direction.

Thanks,

Hi,
i am try to read from a file and then split the data and store them in array
but i am getting an error. can someone please point to the right direction

here is the file i am trying to read from

8
223432,YNYYYYYYYYYNYNYNYYNY-
623123,YNYNYNYYNY--YNYNYYNY
912234,YYYNYNYNYNYYNYYNYYNY
612356,YYYNYFYNYYNYYNYYNYYN
165478,YYYNYYYYY-NYYNYYNYYN
612321,YYYNYFYNYYNYYNYYNYYN
165213,YYYNYYYYY-NYYNYYNYYN

my code is as below

[code]

            Dim Result As DialogResult 
    Dim strFileName As String
    Dim sreStreamReader As IO.StreamReader
    Dim strRecord As String
    Dim strRecord1 As string
    Dim strField(1) As string 
    Dim intCount As Integer = 0
    Dim mstrName(7) As string
        Dim mintMark(7) As string

    Try
        Result = OpenStudentResponsesFile.ShowDialog
        If (Result = Windows.Forms.DialogResult.OK) Then
            strFileName =OpenStudentResponsesFile.FileName 
            'open file
            sreStreamReader = IO.File.OpenText(strFileName)
            strRecord = sreStreamReader.ReadLine()& vbNewLine
            MessageBox.Show (strRecord)
            'read file
            While (sreStreamReader.Peek <> -1)
            strRecord1 = sreStreamReader.ReadLine()

            strField = strRecord1.Split(",")

            mstrName(intCount) = strField(0)
            mintMark(intCount) =strField(1)             
            intCount = intCount + 1
            lbldisplay.Text=strField(1)
            End While
            sreStreamReader.Close()

        End If

    Catch ex As Exception
        MessageBox.Show (ex.Message)
    End Try
End Sub

[/code]

Thanks very much, appreciate your help

yes my file only contain this line of code "TFTTTTTTFFTFTFTTTTFF" .
What i am trying to do is read and store it in an array of Strings and then display the result.

Hi,

Thanks for the feedback, it seems to work but the problem is it is not displaying the right results. i am trying to display this characters TFTTTTTTFFTFTFTTTTFF
To you why this is happening..

Thanks

hi,
i am trying to read from a text file and store the data in an array but i don't know how to get started with my code. can someone please get me started here.

i have start with the code for locating the file, but i am having difficulty reading the file.

Dim strFileName As String
OpenAnswerFile.ShowDialog()
strFileName = OpenAnswerFile.FileName
MessageBox.Show(strFileName) 'message box showing the file path

Hi,
i want to write a program that will automate my backup on a windows using python but i have no idea how to get started. can someone please point me to the right direction.

thanks in advance

hi,
can someone please advice what i have done wrong here. i have call the function "void DetermineFine(int speed, char Drunk)" but when i compile and run. i am getting no display on the screen. that is if i enter the speed as 70 or greater 70 and y for drunk or n for not drunk.

the code is as below:

[CODE]#include<iostream>

include<stdlib.h>

using namespace std;

void telluser()
{

int speed;
char character;

cout<<"Enter the speed in KM/HR"<<endl<<"\n:";
cin>>speed;
cout<<"Are you Drunk?"<<endl<<"\n:";
cin>>character;

}

int DetermineSpeed()

{
int speed;
char character;
if(speed> 60 && speed <65 && character == 'n')
{
cout<<"Warning"<<endl;
}
else if(speed> 60 && speed <65 && character == 'y')
{
cout<<"Warning + Take a shower"<<endl;
}
}

bool DetermineDrunk()
{
int speed;
char character;
if(speed == 65 && speed < 70 && character == 'n')
{
cout<<"$7 $5 fine for each km/hr over 60 km/hr"<<endl;
}
else if(speed == 65 && speed < 70 && character == 'y')
{
cout<<"$7 fine for each km/hr over 60 km/hr + Take a shower"<<endl;
}
}

void DetermineFine(int speed, char Drunk)
{

 if(speed >= 70 && Drunk =='n')
 {
   cout<<"$5 fine for each km/hr over 60 km/hr up to and including 70 km/hr"
       <<"$10 fine for each km/hr over 70 km/h"<<endl;
 }

 else if(speed >70 && Drunk == 'y')
 {
   cout<<"$7 fine for each km/hr over 60 km/hr up to and including 70 km/hr"
       <<"$15 fine for each km/hr over 70 km/hr"
       <<"Spend the day/night in cell until become ...

[QUOTE=iamthwee;1211321]You have forgot to call it![/QUOTE]
Thank you all for your feedback it helps me a lot.

how to i call it

Hi,
i am having some difficulty calling this function, can someone please point out what i have done wrong here. The code is as below

appreciate your help.

[CODE]#include<iostream>

include<stdlib.h>

using namespace std;

void speed_value(int input)
{
int speed;
char character;
if(speed > 60 && speed <65)
{
cout<<"Warning"<<endl;
}

else if(speed > 60 && speed <65  && character == 'y')
{
  cout<<"Warning + take a shower"<<endl;
}

cout<<endl;

}

int main()
{

int speed;
char character;

cout<<"Enter the speed in KM/HR"<<endl<<"\n:";
cin>>speed;
cout<<"Enter y if drunk or n if not drunk"<<endl<<"\n:";
cin>>character;
cout<<speed_value<<endl;

system("PAUSE");
return 0;

}
[/CODE]

Thanks very much. i really appreciate your help. That was very helpful.

sabiut

[QUOTE=snippsat;1207189][CODE]def list_sort(input_list,):
'''Sort a list'''
return sorted(input_list)

def remove_dup(input_list):
'''Remove duplicate from a list'''
return set(input_list)

def main():
'''This is called a doc string'''
my_list = [5,4,2,8,4]

#First we se what the functions dos
print list_sort(my_list)
print remove_dup(my_list)
print '-'*20     

#Then we can combine them,first remove duplicate then sort    
remove_duplicate = remove_dup(my_list)
print list_sort(remove_duplicate)   

if name == 'main':
main()

'''-->Output
[2, 4, 4, 5, 8]
set([8, 2, 4, 5])

[2, 4, 5, 8]
'''
[/CODE]
You can look at this.
The code is pretty clear,but just a short explanation because you new to this.

Both function take one [ICODE]argument[/ICODE].
The argument in this case is my_list
When [ICODE]return [/ICODE]is done function is finish.
You can change return with print,and call it like this [ICODE]list_sort(my_list)[/ICODE].
Then you just print out result in the function,nothing get returned out.

You see the avantage when using return,you can have many function return jobb you want to do.
And in the main() you can pick upp all data and print it out.[/QUOTE]

Thanks for responding, how to i test this

def list_sort(input_list,):
'''Sort a list'''
return sorted(input_list)

[QUOTE=snippsat;1207059][CODE]IDLE 2.6.4

word = raw_input("Please enter a string:")
Please enter a string:racecar

raw_input is returing a string so dont use "str"

input_word = "word"
input_word
'word'

Do you see the error now.

word_rev = word[::-1]
word_rev
'racecar'
if input_word == word_rev:
print "The word you have enterd is a palindrome"
else:
print"The word you have entered is not a palindrome"

The word you have entered is not a palindrome

Off course because you are comparing against "input_word" that is "word" not "racecar"

make it easy

word = raw_input("Please enter a string:")
Please enter a string:racecar
if word == word[::-1]:
print "The word you have enterd is a palindrome"
else:
print"The word you have entered is not a palindrome"

The word you have enterd is a palindrome

[/CODE]

A function for this could look like this.
[CODE]def is_palindrome(my_string):
return my_string.lower() == my_string[::-1].lower() [/CODE][/QUOTE]

Thanks very much for your help. You a are genius.
i also want to sort a list of integers into increasing order but i am having difficulties figuring how the function should look like. i have start with the code as below. can someone please show me how the function of the code should look like.

Thanks in advance

a=[4,2,6,0,7,3,9,21,15,12,17,1,0]
a.sort()
a
[0, 0, 1, 2, 3, 4, 6, 7, 9, 12, 15, 17, 21]

[QUOTE=woooee;1206769]Add some print statements to ferret out what's happening, for example:
And Idle (comes with Python) is much easier to use than the Python shell/command line. [CODE]word=str(raw_input("Please enter a string:"))

Don't use 'string' as a variable name

input_string ="word"
word_rev =word[::-1]

print "comparing", input_string, word
if (input_string == word_rev):
print "The word your have entered is a palindrome"
else:
print"The word you have entered is not a palindrome" [/CODE]
And note that "banana" is not a palindrome, so you should use another word like "racecar".[/QUOTE]

Hi,

I have rewrite the code, however when i enter the word "racecar" as stated. i am still getting "The word you have entered is not a palindrome. i think there must be something that i am missing here. can someone please advise help me with this. the code is as below.

Thanks in advance.

word = str(raw_input("Please enter a string:"))
Please enter a string:racecar
input_word = "word"
word_rev = word[::-1]
print "comparing",input_word,word
comparing word racecar
if(input_word == word_rev):
print "The word you have enterd is a palindrome"
else:
print"The word you have entered is not a palindrome"

The word you have entered is not a palindrome

[QUOTE=sabiut;1206693]Hi,
i need your expertise in this one. i am new to python, i want to write an algorithm that takes a string as input and determines whether or not it is a palindrome.

please point me to the right direction.

Thanks in advance.
sabiut[/QUOTE]

Hi
Thanks for your prompt reply i have written the code as below. i don't know what i did wrong, but it keeps giving me the"The word that you have enter is not palindrome"

can you please help me figure out what i did wrong?

Thanks,

word=str(raw_input("Please enter a string:"))
Please enter a string:banana
string ="word"
word_rev =word[::-1]
if(string == word_rev):
print"The word your have enter is a palindrome"
else:
print"The word you have enter is not a palindrome"

The word you have enter is not a palindrome

Hi,
i need your expertise in this one. i am new to python, i want to write an algorithm that takes a string as input and determines whether or not it is a palindrome.

please point me to the right direction.

Thanks in advance.
sabiut