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
Angelina_Jolie [31]
4 years ago
8

PYTHON Write a grade program using a function called computegrade that takes a score as its parameter and return a grade as a st

ring Score Grade >0.9 A >0.8 B >0.7 C programme execution: Enter score: 0.9 A Enter score: perfect Bad scor
Computers and Technology
1 answer:
makvit [3.9K]4 years ago
3 0

def computeGrade(float grade, str a){

a = "A" if a > 0.9 else a = "B" if a > 0.8 else "C"

return a;

}

print(a)

You might be interested in
What are the different types of topology?​ in details
wlad13 [49]

Answer:

<h2> <u>NETWORK</u> <u>TOPOLOGY</u> .</h2>

This tefers to how nodes are connected to the network.

Types of topology.

  • Physical topology.
  • Logical topology.

In physical topology,nodes are connected physically using wires(cables).

Types of physical topology include:

  • Bus topology
  • Tree topology
  • Hybrid topology
  • Star topology
  • Ring topology.

Hope it helps you,any question so far...comment !!!

3 0
2 years ago
Read 2 more answers
Scanner can be used to read tokens from a String literal Scanner can be used to read tokens from the console window (user input)
Paladinen [302]

Answer:

Scanner can be used to read tokens from the console window (user input)

Explanation:

Scanner is a class used in some programming languages to obtain inputs from users.

It is mostly well developed in Java programming language and used exclusively for taking and obtaining inputs.

Scanner takes input in primitive types such as doubles, floats and integers. IT also takes string inputs.

Here is a code snippet where the class scanner is used:

         Scanner input = new Scanner (System.in)

The code above creates an object of the scanner class

7 0
4 years ago
What is one way the Design tab in the PowerPoint Online application is used?
Vikentia [17]
The transition slides
6 0
3 years ago
Read 2 more answers
You are given a file consisting of students’ names in the following form: lastName, firstName middleName. (Note that some studen
pishuonlain [190]

Answer:

#include <iostream>  // header file for input output functions

#include <string>  // header file for string manipulation

#include <fstream>  // for handling file functions  

using namespace std;  //namespace is used to identify objects like cout, cin

void NamesFunction()  {

// Function to convert names to format firstName middleName lastName    string Name;  //String type variable to store full name

ifstream DataFile;   //used to read input from a file

ofstream OutputFile;  // used for writing in a file

string lastName;  // string type variable to store last name

string firstName;  // string type variable to store first name

int position;  // used to store position of a specified character in the string

int size;  // stores length of full name

DataFile.open("inputtexthere.txt");

//opens text file using object DataFile

OutputFile.open("outputext.txt" );

//opens the text file using object OutputFile

do  {  //start of Do while loop

getline(DataFile, Name);  //reads full names from input stream

position = Name.find(",");  // stores position of the , in the name

lastName = Name.substr(0, position);  

// stores substring last name from full name

size= Name.length();  //store the length of the entire name

firstName = Name.substr(position + 2, size);  

/* stores first name substring from entire name string with the help of specified position */

OutputFile<< firstName << " "; //output first name  in text file

cout << firstName << " ";  

OutputFile<< lastName << endl;  //outputs last name in text file

cout << lastName << endl;   }

    while (DataFile.eof() == false);  

//loop continues until the end of input file is reached

DataFile.close();  //closes input file

OutputFile.close();  }  //closes output file

int main(int argc, char *argv[])  //start of main function

{   NamesFunction();  // calls NamesFunction()

}

Explanation:

The brief description of included header files is mentioned in the comments added to the program. Lets begin from the NamesFunction()  function.

The string variable Name contains the entire string of full names. Then ifstream class is used which is used to read the input file using an object. The object here is DataFile. ofstream is used to write on a file using an object which is named as OutputFile here. firstName and lastName holds first and last names. position variable stores the specified position. Here the  position stores the index position of comma (,) in the string which comes between the lastName and firstName in the input file. size variable holds the length of the Name string.

The function substr is used here to divide the string into substring which is the part of the string that starts at character position and traverses through the specified length of characters.

Here to get the last name in the Name string, substr is used which has two parameters 0 and position means that the substring is obtained starting from 0 position of string and ends where it encounters (,).

Similarly to get the first name, this function is used and it has two parameters; position+2 and size which states that substring will start from two places after (,) and ends till the length of the string. Here position+2 means that it will skip the space between the first name and last name.

Next the names are displayed and stored in the output file via the OutputFile object in the format : firstName middleName lastName

close function will close both the input and output files

Main function calls this function NamesFunction to execute.

5 0
4 years ago
Write a function int guessing_game(num, rangemin, rangemax)that takes an integer and plays a guessing game with the user. Use th
n200080 [17]

Answer:

Check the explanation

Explanation:

Code:

#include <stdio.h>

int ask_in_range(int min, int max)

{

int n;

printf("Please guess a number: ");

scanf("%d", &n);

 

while(n<min || n>max)

{

printf("Your number is outside of [-100, 100] range. Please enter a number: ");

scanf("%d", &n);

}

 

return n;

}

int guessing_game(int num, int rangemin, int rangemax)

{

printf("Hello and welcome to the game.\n");

printf("You need to guess a number between -100 and 100.\n");

 

int count = 1;

int guess = ask_in_range(rangemin, rangemax);

 

while(guess!=num)

{

if(guess<num)

printf("Too low!\n");

else

printf("Too high!\n");

 

guess = ask_in_range(rangemin, rangemax);

count++;

}

 

printf("Good job! You took %d guesses.\n", count);

return count;

}

int main()

{

int count = guessing_game(13, -100, 100);

return 0;

}

Kindly check the attached images below to see the CODE SCREENSHOT and CODE OUTPUT.

6 0
3 years ago
Other questions:
  • Jessica has a balance of $2,200 on her credit card with an 18% interest rate. Her credit card company doesn’t require a minimum
    15·1 answer
  • Which type of graph or chart will you use to show changes in data points?
    5·1 answer
  • You are informed that all the users within the network are unable to access the Internet. You decide to start troubleshooting fr
    12·1 answer
  • Match the personality traits with their description
    9·2 answers
  • assume that you want to sort an array have 100000 elements which algorithm (insert sort algorithm or quick sort algorithm) is th
    12·1 answer
  • Find what the secret message is. Get Brainliest if you are fast and correct.
    13·2 answers
  • Book information (overriding member methods) Given main() and a base Book class, define a derived class called Encyclopedia. Wit
    12·1 answer
  • Define the instance method inc_num_kids() for PersonInfo. inc_num_kids increments the member data num_kids. Sample output for th
    6·1 answer
  • Research and recommend the most appropriate VPN technology. The most likely solution is either an Internet Protocol Security (IP
    5·1 answer
  • What two characteristics describe an ftp connection?.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!