{"id":10082,"date":"2021-09-30T12:00:11","date_gmt":"2021-09-30T06:30:11","guid":{"rendered":"https:\/\/python-programs.com\/?p=10082"},"modified":"2021-11-22T18:35:27","modified_gmt":"2021-11-22T13:05:27","slug":"python-program-to-create-a-class-in-which-one-method-accepts-a-string-from-the-user-and-another-prints-it","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-create-a-class-in-which-one-method-accepts-a-string-from-the-user-and-another-prints-it\/","title":{"rendered":"Python Program to Create a Class in which One Method Accepts a String from the User and Another Prints it"},"content":{"rendered":"

Beginners and experienced programmers can rely on these Best Java Programs Examples<\/a> and code various basic and complex logics in the Java programming language with ease.<\/p>\n

Object-Oriented Programming(OOPS):<\/strong><\/p>\n

Object-oriented programming (OOP) is a form of program structure that involves grouping related characteristics and activities into separate objects.<\/p>\n

Objects are conceptually similar to system components. Consider a program to be a sort of factory assembly line. A system component processes some material at each step of the assembly line, eventually changing raw material into a finished product.<\/p>\n

An object comprises data, such as the raw or preprocessed materials at each step of an assembly line, as well as behavior, such as the action performed by each assembly line component.<\/p>\n

Python, like other general-purpose programming languages, has always been an object-oriented language. It enables us to create a program with an Object-Oriented approach. Classes and objects are simple to build and utilize in Python.<\/p>\n

Using classes and objects, an object-oriented paradigm is used to construct the code. The object is associated with real-world entities such as a book, a house, a pencil, and so on. The oops notion is concerned with building reusable code. It is a common strategy for solving problems by constructing objects.<\/p>\n

The task is to write a Python program that creates a class with one method that accepts a string from the user and another that prints it.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Enter some random string = btechgeeks<\/pre>\n

Output:<\/strong><\/p>\n

The string = btechgeeks<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Enter some random string = samokestring<\/pre>\n

Output:<\/strong><\/p>\n

The string = samokestring<\/pre>\n

Program to Create a Class in which One Method Accepts a String from the User and other Prints it in Python<\/h2>\n

Below is the full approach for writing a Python program that creates a class with one method that accepts a string from the user and another that prints it.<\/p>\n

Approach:<\/strong><\/p>\n