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
Pepsi [2]
3 years ago
14

Define a Python function called leng_of_str to calculate the length of a string (Hint: Do not use the len function to find the l

ength of string"" Use for loop to find the length of string.)

Computers and Technology
1 answer:
Slav-nsk [51]3 years ago
7 0

Answer:

The code is attached.

Explanation:

  1. the function accepts string as a parameter
  2. inside fuction there is a caunter variable initialized 0
  3. for every character in the string counter increases by 1
  4. returns final value of i as an integer, which is also the length of the string given

You might be interested in
The function of network switch is to _____.
enyata [817]

Answer:Its C.

Explanation:

3 0
3 years ago
A. Modify the FitnessTracker class that includes data fields for a fitness activity, the number of minutes spent participating,
Elenna [48]

Answer:

It keeps saying servers fully loaded

Explanation:

5 0
2 years ago
Write any four common hardware devices​
marishachu [46]

Answer:

Input devices: For raw data input.

Processing devices: To process raw data instructions into information.

Output devices: To disseminate data and information.

Storage devices: For data and information retention.

8 0
2 years ago
Write a user-defined function that calculates the GPA. For the function name and arguments, use the following: The input argumen
QveST [7]

Answer:

#include <iostream>

#include <vector>

using namespace std;

void calGPA();

vector<int> g;

vector<int> h;

int main(){

   char pushMore = 'y';

   int fg, fh;

   for (;;){

       if (pushMore == 'n'){

           break;

       } else{

           cout<< "Enter integer for grade: ";

           cin>> fg;

           cout<< "Enter integer for credit hours: ";

           cin>> fh;

           g.push_back(fg);

           h.push_back(fh);

           cout<< "Do you want to add more grade and credit hours? y/n: ";

           cin>> pushMore;

       }

   }

   calGPA();

}

void calGPA(){

   double total = 0, GPA;

   for (int i = 0; i < g.size(); ++i) {

        total +=  g.at(i) * h.at(i) ;

   }

   cout<< "The GPA is : "<< total/g.size();

}

Explanation:

The C++ source code above defines two vectors 'g' and 'h'. The latter holds the grades of a student while the former holds the credit hours for the subject taken. The void 'calGPA' function calculates and prints the student's GPA.

7 0
3 years ago
Suppose you wish to develop a matrix-multiplication algorithm that is asymptotically faster than Strassen’s algorithm. Your algo
Kazeer [188]

Answer:

The number of subproblems are given as T(n)=a*T(n/8)+\theta(n^2) while the value of T(n) to be less than S(n) is for 342.

Explanation:

The number of subproblems are given as

T(n)=a*T(n/8)+\theta(n^2)

Asymptotic running time for Strassen’s algorithm is S(n)=\theta(n^{log(7)})

Now, when a increases, number of subproblems determines the asymptotic running time of the problem and case 1 of master theorem applies. So, in worst case, asymptotic running time of the algorithm will be

T(n)=\theta(n^{logb(a)})=\theta(n^{log8(a)})=\theta(n^{log_{2}(a^{1/3})})

Now, for T(n) to be smaller than S(n)

n^{loga^{1/3}}

So,

log(a^{(1/3)})

So,

a=342

5 0
3 years ago
Other questions:
  • A short-circuit evaluation is where each part of an expression is evaluated only as far as necessary to determine whether the en
    14·1 answer
  • Is there truth? Does truth exists?
    14·2 answers
  • Write code that uses the input string stream inSS to read input data from string userInput, and updates variables userMonth, use
    8·1 answer
  • Diverting an attacker from accessing critical systems, collecting information about the attacker's activity and encouraging the
    8·1 answer
  • What output is generated by this for loop?
    6·1 answer
  • Why do certain words change color in Python?
    6·1 answer
  • Each pixel includes 3 colors; Red, Green and Blue. Each color uses 8 bits to store it's intensity. How many Bytes are needed for
    12·1 answer
  • Consider the following class definition.
    7·1 answer
  • Explain briefly why it is sometimes necessary to roll software back to a previous version, a procedure called "software
    9·1 answer
  • Explain why the receptionist responded as indicated in the following scenario.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!