Knowee
Questions
Features
Study Tools

What is missing from the following code, to work with the function?student(name,class):                print(f"my name is {name}, I am in class {class}")student("udin","TI22A")AstringsBdefCprintDcolon

Question

What is missing from the following code, to work with the function?student(name,class):                print(f"my name is {name}, I am in class {class}")student("udin","TI22A")AstringsBdefCprintDcolon

🧐 Not the exact question you are looking for?Go ask a question

Solution

To make the provided code work correctly, you need to add the keyword def to define the function. Here is the corrected code:

def student(name, class_):
    print(f"my name is {name}, I am in class {class_}")

student("udin", "TI22A")

Note that I also changed the parameter name class to class_ because class is a reserved keyword in Python.

So, the missing part is:

B. def

This problem has been solved

Similar Questions

What is the output of the following code?def student(name):                print(f'Hello{name} , welcome!')student('Udin')AUdinBHello Udin, welcome!CHello, WelcomeDstudent

The output of the following code is ?def student(name,class,major = Informatic Engineering):                print(f"my name is {name}, my class is {class} and major is {major}")student(“udin”,”TI22E”)Amy name is udin, my class is TI22E and major is Mechanical EngineeringBmy name is udin, my class is TI22ECmy name is udin, my class is TI22E and major is Informatic EngineeringDmy name is udin

What will be the output of the following Python code? class student: def __init__(self): self.marks = 97 self.__cgpa = 8.7 def display(self): print(self.marks)obj=student()print(obj._student__cgpa) The program runs fine and 8.7 is printed Error because private class members can’t be accessed Error because the proper syntax for name mangling hasn’t been implemented The program runs fine but nothing is printedClear ResponseSave & Next

class Student:    def __init__(self,name,id):        self.name=name        self.id=id        print(self.id)std=Student("Simon",1)std.id=2print(std.id)

Which of the following codes is correct for writing functions?Astudent defs:Bdef student():Cdef student{}:Ddef student

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.