.Store your favourite subject’s name in a variable. Write a program to join that variable to a proper sentence and print it.

.Store your favourite subject’s name in a variable. Write a program to join that variable to a proper sentence and print it.

Example: “My favourite subject is Computer Science

pls answer why u r not answering

About the author
Charlotte

2 thoughts on “.Store your favourite subject’s name in a variable. Write a program to join that variable to a proper sentence and print it.<br />”

  1. Storing favourite subject name – Python

    What we need to do

    We would take a user input string first, to store favourite subject’s name in a variable.

    We know that the input() function returns a string, string is one of the basis types in Python that store text.

    We then join that variable and we print the result.

    [tex]\rule{300}{1}[/tex]

    The Program

    subject=input(‘Enter your favourite subject name:’)

    print(“My favourite subject is, subject”)

    [tex]\rule{300}{1}[/tex]

    Sample Run

    Enter your favourite subject name: Computer Science

    My favourite subject is Computer Science

    Reply
  2. Answer:

    #Done in python…

    k=input(“What is your favourite subject?”)

    print(“Your favourite subject is “,k)

    //JAVA

    import java.util.*;

    class abc{

    public static void main (String ar []){

    Scanner sc=new Scanner(System.in);

    System.out.println(“What’s your favourite subject?”);

    k=sc.nextLine();

    System.out.println(“Your favourite subject is “+k);

    }

    }

    Reply

Leave a Comment