SL MULTIMEDIA TUTORIAL

Well-known member
  • Jul 27, 2020
    1,709
    7,090
    113
    United States
    mekata Code enne kohomada 👀


    Complete the code to take the input as an integer and output a square of "*" characters.
    An input can be taken by using the following line.
    val = int(input())


    For example, if the input is 2 and 5 respectively:



    For example:

    InputResult
    2**
    **
    5*****
    *****
    *****
    *****
    *****
     

    Ted Mosby

    Well-known member
  • Aug 29, 2021
    594
    1,604
    93
    2 nested loops
    both from 0 to input value
    print * in the inner loop
    end of the outer loop print a new line
     

    SL MULTIMEDIA TUTORIAL

    Well-known member
  • Jul 27, 2020
    1,709
    7,090
    113
    United States
    val=int(input())
    for numbers in range(0,val):
    (Indent)for n in range(0,val):
    (Indent)(indent)print("*",end=' ')
    (Indent)print("")

    Indent kiyala tiyena tanwala indents tiyanna ona. Meke tiwwata ewa pennanne na. :dull:
    def get_input( a,b):
    result = a+b
    return result

    a = int(input("Enter number one: "))
    b = int(input("Enter number two: "))

    print(get_input(a,b))

    me Code ekata error eka hadanna vidhiyak nadda

    ***Run error***
    Traceback (most recent call last):
    File "__tester__.python3", line 17, in <module>
    get_input()
    TypeError: get_input() missing 2 required positional arguments: 'a' and 'b'
     

    asknrk

    Well-known member
  • Feb 10, 2007
    2,857
    804
    113
    @Thusithaya
    1646757125402.png

    Python:
    def get_input(a,b):
        result = a+b
        return result
    
    a = int(input("Enter number one: "))
    b = int(input("Enter number two: "))
    
    print(get_input(a,b))
     
    def get_input( a,b):
    result = a+b
    return result

    a = int(input("Enter number one: "))
    b = int(input("Enter number two: "))

    print(get_input(a,b))

    me Code ekata error eka hadanna vidhiyak nadda

    ***Run error***
    Traceback (most recent call last):
    File "__tester__.python3", line 17, in <module>
    get_input()
    TypeError: get_input() missing 2 required positional arguments: 'a' and 'b'

    Meka harine. Uba function eka call karaddi arguments deela na wage.
     
    • Like
    Reactions: webDevNinja

    SL MULTIMEDIA TUTORIAL

    Well-known member
  • Jul 27, 2020
    1,709
    7,090
    113
    United States
    Meka harine. Uba function eka call karaddi arguments deela na wage.
    1. Read the first two lines from a text file named "file1.txt"
    2. Write the two lines read from "file1.txt" to a new file called "file2.txt"
    3. Read "file2.txt" and Print the contents
    me Code eka waradida

    f1 = open('file1.txt')
    f2 = open('file2.txt')

    file = open("f2", 'r+')
    contents = file.readlines(2)
    file.close

    with open("f2", 'a') as file :
    file.write(contents)

    print(contents)
     

    olu bakka

    Well-known member
  • Aug 18, 2011
    23,247
    24,119
    113
    val=int(input())
    for numbers in range(0,val):
    (Indent)for n in range(0,val):
    (Indent)(indent)print("*",end=' ')
    (Indent)print("")

    Indent kiyala tiyena tanwala indents tiyanna ona. Meke tiwwata ewa pennanne na. :dull:
    Nested loop natuwat puluwan

    Python:
    val=int(input())
    for i in range(0,val):
       print("*"*val)
     
    1. Read the first two lines from a text file named "file1.txt"
    2. Write the two lines read from "file1.txt" to a new file called "file2.txt"
    3. Read "file2.txt" and Print the contents
    me Code eka waradida

    f1 = open('file1.txt')
    f2 = open('file2.txt')

    file = open("f2", 'r+')
    contents = file.readlines(2)
    file.close

    with open("f2", 'a') as file :
    file.write(contents)

    print(contents)

    File.readline() deparak run karanna wenawa mama hithanne.
     

    Similar threads