UCSC,Mora,SLIIT okkoma chora

Oct 26, 2012
7
1
0
මම දැන් කී දෙනෙක් ගෙන් ඇහුවද අපිට assignment එකකට දුන්න පොඩි Python programme එකක් ලියන හැටි UCSC,Moratuwa,SLIIT එකෙක් වත් දන්නේ නැහැලු.IT කරන උන් IT ගැන දන්නේ නැහැ කියුවහම හරි චාටර් නේද බං..


 

Randike Mendis

Well-known member
  • Oct 16, 2010
    17,253
    1,143
    113
    S.K
    මම දැන් කී දෙනෙක් ගෙන් ඇහුවද අපිට assignment එකකට දුන්න පොඩි Python programme එකක් ලියන හැටි UCSC,Moratuwa,SLIIT එකෙක් වත් දන්නේ නැහැලු.IT කරන උන් IT ගැන දන්නේ නැහැ කියුවහම හරි චාටර් නේද බං..



    IT කියන්නේ ඕක විතරක්ම නෙමෙයි නේ...
    ඔයා ඕක අහන්න Software Developing area (coding side)
    එක කරන කෙනෙක්ගෙන්...
    කකුලේ අමාරුවට E.N.T(උගුර කන නාසය) වෛද්‍යවරයා
    ගාවට ගිහින් එයා බෙහෙත් කලේ නෑ කියුවම වැරදී නේ..
    ෆේක් එක හදන් ආවට කමක් නෑ..
    ඉතින් මේක කියන්නත් ඇපැයි කාට හරි...

    :frown::frown::frown::frown:
     

    chamarams

    Well-known member
  • Nov 22, 2008
    1,908
    344
    83
    inside you hart :D
    ඕක අහපන් codeproject නැත්නම් stackoverflow එකෙන්
    එත් උබට ගෙඩිය පිටින් උත්තර හම්බ වෙන්නේ නැ උස්ත්සහ කරලා බලපන්
    ගැටගහගන්න
     

    119©

    Well-known member
  • Sep 29, 2012
    2,411
    2,151
    113
    ~ගෙදර~
    :lol::lol:උඹ හරි කතාවක් නේ කියන්නේ.මේ ලෝකේ languages කියක් තියනවද eg:C#,java,php,perl,c,c++,J#,python,A+,A++,Ada,ALF,AMPL,AWK.Boo තව හෙන ගොඩක් තියනවා .ඒ ඔක්කොම ඉගෙන ගෙන ඉන්න ඕනේ නැහැ කව්රුත්.ගොඩක් වෙලාවට දන්නේ 2ක් 3ක් තමයි.ඔක්කොම ඉගෙන ගන්න ගියොත් නකිවෙනකම් ම ඉගෙන ගන්න වෙන්නේ.python කව්රුත් පාවිච්චි කරන්නේ නැහැ වැඩිය ලංකාවේ.ටික දෙනෙක් තමයි හොඳටම දන්නා අය ඉන්නේ.ප්‍රශ්නේ දාල තියපන් කව්රු හරි උතර දෙවි.
     
    Last edited:

    119©

    Well-known member
  • Sep 29, 2012
    2,411
    2,151
    113
    ~ගෙදර~
    ඕක අහපන් codeproject නැත්නම් stackoverflow එකෙන්
    එත් උබට ගෙඩිය පිටින් උත්තර හම්බ වෙන්නේ නැ උස්ත්සහ කරලා බලපන්
    ගැටගහගන්න
    :yes::yes::yes:
     
    Oct 26, 2012
    7
    1
    0
    these are the questions we are given

    Q1- describe the difference between global & Local variable in python programming with a simple example programme

    Q2-
    Write a python Programme which prints the odd numbers between 1 and 1000 in the following order..

    1,999,3,997,5,995,7,993,.........

     
    • Like
    Reactions: ZULFAAN

    Tom Riddle

    Member
    Aug 31, 2007
    1,833
    196
    0
    කවුරුවත් මුට උදව් කරන්න එපා

    මූ හදන්න අපිව අවුස්සලා Assignment එක කරවගන්න
     

    dagiya

    Active member
  • Mar 13, 2009
    815
    39
    28
    ජබුක් ලන්තේ...
    Q1- describe the difference between global & Local variable in python programming with a simple example programme


    Global variables are accessible inside and outside of functions. Local variables are only accessible inside the function.

    global_var = 'foo'
    def ex1():
    local_var = 'bar'
    print global_var
    print local_var

    ex1()
    print global_var
    print local_var # this gives an error


    In the example below, the function can access both the global and the local variable. However, trying to access the local variable outside the function produces an error.

    output

    foo
    bar
    foo
    Traceback (most recent call last):
    File "nested_scope.py", line 12,
    in print local_var
    # this gives an error
    NameError: name 'local_var' is not defined



    Q2-
    Write a python Programme which prints the odd numbers between 1 and 1000 in the following order..

    1,999,3,997,5,995,7,993,.........


    Follow the this program and make what you want.

    import math

    def isEven(number):
    if int(number) % 2 == 0:
    return True
    else:
    return False

    def isPrime(number):
    #Make sure that the entered number is positve.
    number = abs(int(number))

    if number < 2:
    return False

    if number == 2:
    return True

    if not number & 1:
    return False

    for x in range(3, int(number**0.5) + 1, 2):
    if number % x == 0:
    return False
    return True

    def isSquare(number):
    #Do this on your own. :P

    number = raw_input("Enter your number: ")

    if isEven(number):
    print str(number) + " is even."
    else:
    print str(number) + " is odd."

    if isPrime(number):
    print str(number) + " is prime."
    else:
    print str(number) + " is not prime."

    if isSquare(number):
    print str(number) + " is square."
    else:
    print str(number) + " is not square."


    source: internet
     
    Last edited:
    • Like
    Reactions: ZULFAAN

    charitharanasingha

    Junior member
  • Dec 6, 2006
    241
    22
    18
    IT kianne podi subject ekak nemei, IT karanava kiala eke thiyena hama magulakma hama ekama igena ganne ne, eka ekaa kamaththa vidiata eka paththak or programming language ekak thoragena eken thama issarahata yanna balanne... Ubage IT gana knowledge eka hodatama therenava... hikz
     

    ZULFAAN

    Well-known member
  • Feb 1, 2009
    2,118
    589
    113
    35
    Great Galle
    Q1- describe the difference between global & Local variable in python programming with a simple example programme


    Global variables are accessible inside and outside of functions. Local variables are only accessible inside the function.

    global_var = 'foo'
    def ex1():
    local_var = 'bar'
    print global_var
    print local_var

    ex1()
    print global_var
    print local_var # this gives an error


    output

    foo
    bar
    foo
    Traceback (most recent call last):
    File "nested_scope.py", line 12,
    in print local_var
    # this gives an error
    NameError: name 'local_var' is not defined



    Q2-
    Write a python Programme which prints the odd numbers between 1 and 1000 in the following order..

    1,999,3,997,5,995,7,993,.........


    Follow the this program and make what you want.

    import math

    def isEven(number):
    if int(number) % 2 == 0:
    return True
    else:
    return False

    def isPrime(number):
    #Make sure that the entered number is positve.
    number = abs(int(number))

    if number < 2:
    return False

    if number == 2:
    return True

    if not number & 1:
    return False

    for x in range(3, int(number**0.5) + 1, 2):
    if number % x == 0:
    return False
    return True

    def isSquare(number):
    #Do this on your own. :P

    number = raw_input("Enter your number: ")

    if isEven(number):
    print str(number) + " is even."
    else:
    print str(number) + " is odd."

    if isPrime(number):
    print str(number) + " is prime."
    else:
    print str(number) + " is not prime."

    if isSquare(number):
    print str(number) + " is square."
    else:
    print str(number) + " is not square."


    source: internet
    :shocked::shocked::shocked::):):cool:

    THANKS MACHAN
    matath oka me dawaswala jeewana prashnayak wela tibune..
    shakya kiyanne mage batchek tamai,
    onna mama rep dunna.
    lakunu awama pm ekak daannamko :)

    11.gif