Computer Science Question

Q1) Write a code in python that display the list:

                Final=[0,-3,5,100,5,10,30]

  1. Print the list

  2. Find how many elements the list contains

  3. Add number 3 to the third element which is 5. It should be replicated by 8.(5+3)

  4. Print the new list. (The output should be [0,-3,8,100,5,10,30])

  5. Find the last element of the list using length

Q2) what is the difference between code 1 and code 2?

                Code 1:

F0=open(“foo.txt”,”wb”)

Foo.closed

Code 2:

F0=open(“foo.txt”,”wb”)

Foo.close()

Q3) deff(a,b=1, c=2)

This defined function prints values of arguments passed to the parameters, the write output of:

                F(2, c=2)

                F(c=100, a=110)

Q4) The syntax of opening file in python for both reading and writing format is:

Q5) write a code in python that welcomes the user when the username and password is correct.

  • Username: “python”

  • Password: “12345”

Output should be

DETAILED ASSIGNMENT

20210408155318lab_sp_mid

Powered by WordPress