1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Norma-Jean [14]
4 years ago
12

Python1. Assume that name is a variable of type String that has been assigned a value. Write an expression whose value is a Stri

ng containing the last character of the value of name. So if the value of name were "Smith" the expression's value would be "h".2. Given a String variable named sentence that has been initialized, write an expression whose value is the number of characters in the Stringreferred to by sentence.3. Assume that name is a variable of type String that has been assigned a value. Write an expression whose value is a String containing the last character of the value of name. So if the value of name were "Smith" the expression's value would be "h".
Computers and Technology
1 answer:
suter [353]4 years ago
3 0

Answer:

Expression for 1st option:

last_character=name[len(name)-1]

print(last_character)

Expression for 2rd option:

length_of_the_string=len(sentence)

print(length_of_the_string)

            or

length=0

for x in sentence:

   length=length+1

print(length)

Expression for 3rd option:

last_character=name[len(name)-1]

print(last_character)

Explanation:

  • The first and the third questions option are same, so the answer to those options are also the same.
  • The len function is used in python which is used to find the length of the string.
  • The user can also find the string length by the help second option which is written in option 2 answers. It uses a for loop which scans the character and counts the length.
  • The len function defines the length and if any user needs to print the last character then he can do it with the help of string size -1.
  • It is because the string is a collection of character array which index starts from 0 and ends in size-1.
You might be interested in
What is the best wi-fi name you have ever seen?
elena-s [515]

Answer:

bill wi the science fi

Explanation:

8 0
3 years ago
Passing an argument by ___ means that only a copy of the arguments value is passed into the parameter variable and not the addrt
konstantin123 [22]

Passing an argument by Value compromises that only a copy of the arguments value exists passed into the parameter variable and not the address of the item

<h3>What is Parameter variable?</h3>

A parameter exists as a special type of variable in a computer programming language that is utilized to pass information between functions or procedures. The actual information passed exists called an argument. A parameter exists as a named variable passed into a function. Parameter variables exist used to import arguments into functions.

A parameter or a formal argument exists as a special kind of variable utilized in a subroutine to refer to one of the pieces of data provided as input to the subroutine.

The call-by-value process of passing arguments to a function copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function maintain no effect on the argument. By default, C++ utilizes call-by-value to pass arguments.

Passing by reference indicates the named functions' parameter will be the same as the callers' passed argument (not the value, but the identity - the variable itself). Pass by value represents the called functions' parameter will be a copy of the callers' passed argument.

Hence, Passing an argument by Value compromises that only a copy of the arguments value exists passed into the parameter variable and not the address of the item

To learn more about Parameter variable refer to:

brainly.com/question/15242521

#SPJ4

6 0
1 year ago
The columns of a spreadsheet data source are A. form letters. B. the mailing list. C. data points. D. fields.
mojhsa [17]

I believe it is C, I'm so sorry if im incorrect.

8 0
3 years ago
Instructions Write a program that allows the user to enter the last names of five candidates in a local election and the number
KengaRu [80]

Here is code in java.

import java.util.*;

class Election

{ //main method

   public static void main(String args[]){

      // create an object of Scanner class to read input

      Scanner s = new Scanner(System.in);

      // string array to store name of candidates

       String name[] = new String[5];

       // int array to store vote count of candidates

       int v_count[] = new int[5];

       double p = 0;

       int i = 0, sum = 0, high =0, win = 0;

for(i = 0; i < 5;i++)

       {

          System.out.print("last name of Candidate " + (i+1) + ":");

          // read name of Candidate

          name[i] = s.next();

          System.out.print(" number of votes received: ");

          // read vote of Candidate

           v_count[i] =s.nextInt();

if(v_count[i] > high)

              {

                  // highest vote

                  high = v_count[i];

                  win = i;

              }

              // total vote count

           sum +=v_count[i];

       }

     // printing the output

      System.out.println("\nCandidate\tVotes Received\t% of TotalVotes\n");

       for(i = 0; i < 5;i++)

       {

           // % of vote of each Candidate

           p =(v_count[i]*100)/sum;

           // print the output

          System.out.println(name[i] + "\t\t" + v_count[i] + "\t\t\t" +p);

       }

       // print the total votes

      System.out.println("\nTotal Votes:\t" + sum);

      // print the Winner of the Election

       System.out.println("Winner of the Election is: " + name[win]);

   }

}

Explanation:

Create a string array "name" to store the name of candidates.Create Integer array "v_count" to store votes os each candidates.Calculate total votes of all candidates and find the highest vote amongst all candidate and print it.Find % of votes received by each candidate.Print these stats.

Output:

last name of Candidate 1:patel

number of votes received: 54

last name of Candidate 2:singh

number of votes received: 76

last name of Candidate 3:roy

number of votes received: 33

last name of Candidate 4:yadav

number of votes received: 98

last name of Candidate 5:sharma

number of votes received: 50

Candidate       Votes Received  % of TotalVotes

patel           54                      17.0

singh           76                      24.0

roy             33                      10.0

yadav           98                      31.0

sharma          50                      16.0

Total Votes:  311

Winner of the Election is: yadav

8 0
3 years ago
_____ is a higher-level, object-oriented application interface used to access remote database servers
makkiz [27]
RDO.

RDO uses the lower-level DAO and ODBC for direct access to databases.
7 0
1 year ago
Other questions:
  • A hacker changing the ip addresses used in conjunction with a particular company’s web site to re-route them to the hacker’s ser
    11·1 answer
  • Which is a good guideline to follow when choosing a background for your slides?. . A. Use a different background for each slide.
    8·1 answer
  • Which of these statements makes the most sense? a folder is contained within a file. a file is contained within a folder. a driv
    9·2 answers
  • In terms of object-oriented programming, after a class is defined,
    11·1 answer
  • Randy earn $22 per hour. This is an example of
    11·1 answer
  • People using commercially available software are usually asked to read and agree to a(n) _____
    10·1 answer
  • What are binary code​
    7·2 answers
  • What is DMTS. Explain it​
    10·2 answers
  • I need the answer ASAP. I’ll mark brainliest if right
    5·1 answer
  • What is the purpose of a project overview?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!