diff_months: 4

Introduction to Python Programming CS101

Flat 50% Off Order New Solution
Added on: 2025-06-05 05:28:21
Order Code: LD524152
Question Task Id: 0
  • Subject Code :

    CS101

Python Basics Assignment

Q1. Using Python script as a calculator

Create the variables n, r, p and assign them values 10, 5, and 100 respectively. Then evaluate the following expression in the Python console.

???? = ???? (1 + ????/ 100)n

  1. 100
  2. 89
  1. 189
    1. None of the above

Q2. In a given string format operation, how will you print the given string.

A = 10

B = 20

Str = "There are {} students in the class, with {} who play at least one sport."

  1. print(string.format(a,b))
  2. print(string+a+b)
  1. print(string.format(b,a))
    1. None of the above

Q3. In a given sample string, How do you print a double quoted string in between a regular

string using the escape character?

Sample output = It goes without saying, Time is Money, and none can deny it.

  1. print(It goes without saying, Time is Money, and none can deny )
  2. print(It goes without saying, Time is Money, and none can deny )
  1. print(It goes without saying + Time is Money + and none can deny )
    1. None of the

Q4. What will be the output of the following code? x = lambda a,b: a//b

x(10,3)

  1. 3333333333
  2. 3
  1. 30
    1. 1000

Q5. What will be the output of the following code?

A = 10

B = 12

print("Smaller") if A == B else print("Greater") if A < B>

  1. True
  2. Smaller
  1. Greater
    1. None of the above

Q6. What will be the output of the following code?

  1. [2 7 3 5 4 6]
  2. Type Error
  1. Name Error: name 'numpy' is not defined
    1. None of the above

Q7. Create a string called string with the value as Machine Learning. Which code(s) is/are appropriate to slice the substring Learn?

  1. string[slice(13,8,1)]
  2. string[slice(1,8,1)]
  1. string[8:14]
    1. string[slice(8,13,1)]

Q8. Create a sequence of numbers from 10 to 25 and increment by 4. What is the index of the

value 18?

  1. 3
  2. 2
  1. 0
    1. 1

Q9. Which of the following is true with respect to the below codes?

  1. num1 = num2
  2. num1 ? num2
  1. num1 < num2>
  2. num1 > num2

Q10. A Python Name Error exception is raised when: -

  1. Trying to access a variable which has not been defined
  2. Trying to access a key in a dictionary that does not exist

  1. Accessing a column with misspelled column name
    1. Accessing the function from a module that has not been imported

Q11. What type of exception will be raised for the code given below?

  1. Name Error
  2. Key Error
  1. Value Error
  2. Attribute Error

Q12. A File Not Found Error exception is raised by operating system errors when: -

  1. Trying to create a file or directory which already exists
  1. A file or directory is requested but does not exist in the working directory
  2. Trying to run an operation without the adequate access rights
  1. A directory operation, listdir() is requested on something which is not a directory

Q13 .Consider a variable Z. The value of Z is "ID-5632". Data type of Z is: -

  1. Complex
  2. Character
  1. Integer
    1. Boolean

Q14 .Which of the following variable(s) are character data type?

  1. K= 4
  2. J= Welcome
  1. L= ?
  2. All of the above

Q15. Choose the symbol/s that does not have the ability to convert any values to string?

  1. ( )
  1. {}
    1. #

Q16. Create a dictionary Country that maps the following countries to their capitals respectively:

Country

India

China

Japan

Qatar

France

State

Delhi

Beijing

Tokyo

Doha

Marseilles

Find 2 commands to replace Marseilles with Paris is:

Q17. Create the tuples given below tuple_1 = (1,5,6,7,8)

tuple_2 = (8,9,4)

Identify which of the following code does not work on a tuple.

  1. sum(tuple_1)
  2. len(tuple_2)
  3. tuple_2 + tuple_1
  4. tuple_1[3] = 45

Q18 . How many elements in the following data structure?



Q19. Write a function which finds all pythagorean triplets of triangles whose sides are no greater than a natural number N.

  • Uploaded By : Nivesh
  • Posted on : June 05th, 2025
  • Downloads : 0
  • Views : 158

Order New Solution

Can't find what you're looking for?

Whatsapp Tap to ChatGet instant assistance

Choose a Plan

Premium

80 USD
  • All in Gold, plus:
  • 30-minute live one-to-one session with an expert
    • Understanding Marking Rubric
    • Understanding task requirements
    • Structuring & Formatting
    • Referencing & Citing
Most
Popular

Gold

30 50 USD
  • Get the Full Used Solution
    (Solution is already submitted and 100% plagiarised.
    Can only be used for reference purposes)
Save 33%

Silver

20 USD
  • Journals
  • Peer-Reviewed Articles
  • Books
  • Various other Data Sources – ProQuest, Informit, Scopus, Academic Search Complete, EBSCO, Exerpta Medica Database, and more