Python Input Output Activities 18th March

Home Forums Grade 9 Python Python Input Output Activities 18th March

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #7414
    Eamonn
    Keymaster

    Record your responses here please

    #7415
    Rafael
    Participant

    It firstly asks for the user to enter the name, then the student Id, and lastly course number. After writing all the answers to those questions, it labels in (Name, ID, and class enrollment)
    String literal escape sequence is a sequence of characters from the source character set enclosed in double quotation marks. They are used to represent a sequence of characters.
    When it changes to /t, it means ‘tab’, it is an escape sequence for the tab character.

    #7416
    Rishi
    Participant

    the code first asks you to enter your name, then id and finally your course name. This is all recorded in a specific sequence which is code, id, and course name. Then the code prints your answer in the sequence. SO you are inputting your name id and course name then, the code in implementing it into the code

    #7417
    Kla
    Participant

    The code starts off by asking your name. After you have enter your name, it brings you to the second column which is asking for you to enter your student ID’s number. Finally, it will be asking your course number. After you’ve finished all of the questions. It writes like a summary of you. The double quotation marks is used to represent the sequence of characters.

    #7418
    Peam1223
    Participant

    slide 1
    1. enter name is displayed on the screen. then followed by enter student ID number after that its the course number and once you fill out all the information it will combine all the data in to one sentence stating the name, the id number, and the course.
    2.i think that \n starts a new line.
    3.\t is a space bar. it creates space.

    #7419
    Chien493
    Participant

    Print the answer you enter the number. The int() function converts the specified value into an integer number.

    #7421
    Matthew Sparrow
    Participant

    The output I expected was an error, and it was an error. After you add “num1 = int(firstNumber) and num2 = int(secondNumber)” between lines 2 and 3 nothing changed yet because num1 doesn’t work with firstnumber and num2 doesn’t work with secondnumber. After I changed “difference = firstNumber – secondNumber” to “difference = num1 – num2” the code was working. the purpose of the function int() is to convert the specific value into an integer number. It made the number subtract one another to get the answer.

    #7422
    Fine
    Participant

    name = input(“Enter name: “)
    ID = input(“Enter your student ID number: “)
    course = input(“Enter your course number: “)
    print(name + “‘s ID is” + ID + “\nand is enrolled in “+ course)

    State what is displayed on the screen when you executed the program.
    – Displayed on the screen is a place to enter your name, student ID, and course number. The final result is name+student ID+course number.

    The \n is a “string literal escape sequence” in python. What does this do?
    – In Python, the new line character “\n” is used to create a new line. When inserted in a string all the characters after the character are added to a new line.

    Change the \n to \t and describe what happens to the program output.
    – Replacing /t with /n will replace a line with a tab.

    #7423
    Andrew
    Participant

    The int() function returns the numeric integer equivalent from a given expression. Expression whose numeric integer equivalent is returned. Using int() function we can convert the string input to integer. The below program will get two numbers from the user and print their sum. int() function converts any datatype to integer.

    #7424
    Fine
    Participant

    a. What output do you expect?
    – I expected that the function would not work.
    b. What is the actual output
    – The function did not work due to an error.
    c. Revise the program in the following manner:
    Between lines two and three add the following lines of code:
    num1 = int(firstNumber)
    num2 = int(secondNumber)
    Next, replace the statement: difference = firstNumber – secondNumber
    with the statement: difference = num1 – num2
    Execute the program again. What output did you get?
    – The code is now working. Num1-Num2=difference.
    d. Explain the purpose of the function int().
    – The int() function is used to convert a value into an integer number. The int() function returns an integer object made up of a number or a string x, or 0 if no arguments are provided. To be converted to an integer object, a number or string must be provided.
    e. Explain how the changes in the program produced the desired output.
    – Changes in the program make the code work properly and output the desired output. Without making the changes, the program would have errors that hinders the program from working.

    CODE:
    firstNumber = input(“Enter a number: “)
    num1 = int(firstNumber)
    secondNumber = input(“Enter another number: “)
    num2 = int(secondNumber)
    difference = num1 – num2
    print(“*” * 10)
    print(“Difference = “, difference)

    #7426
    May07
    Participant

    The int() function converts a provided statement to a numeric integer equivalent. We can turn a text into an integer using the int() function. 

    #7427
    Fine
    Participant

    Predict the output and execute the following lines of code.

    name = input(“What is your name? “)
    print(“Your name is”,Name)
    a. Is the output what you would expect? Why or why not?
    – Error, the variable ‘name’ is all in lowercase while the print ‘Name’ ‘N’ is uppercase, so it won’t work.

    b. How can you alter the code so that it functions properly?
    – To make the function work, we change the letters to lowercase.
    So we get the code:
    name = input(“What is your name? “)
    print(“Your name is”,name)

    #7428
    Bob
    Participant

    name = input(“Enter name: “) This code sentence is for entering a name.
    ID = input(“Enter your student ID number: “) This code requires you to enter the ID number (it is recommended to add a limit that you can only enter numbers)
    course = input(“Enter your course number: “) Enter your course name.
    print(name + “‘s ID is” + ID + “\nand is enrolled in “+ course) shows the result.

    #7464
    aanya03
    Participant

    It first ask us to enter our name, then ID number, and the your course name. This is all recorded in this specific sequence which is your name, your ID number, and then your course name. So the input is the name, ID number and Course name, and your output is all of this coming out in a code sequence.

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.
Scroll to Top