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
ladessa [460]
4 years ago
8

Write a function called name_facts that will take a firstname (string) as an input parameter, and print out various facts about

the name, including:
1) its length, 2) whether it starts with the letter A, and 3) whether it contains a Z or X.
To gain full credit for this exercise, you must use string formatting to print out the result. Hints: You will probably want to convert the string to lowercase when checking conditions 2 and 3. You can get by without it, but you'll have to make sure you check both lower and uppercase versions of the letters. You will have to use the in operator for condition 3. You will also probably want to make a separate message for conditions 2 and 3 (depending on the answer) and use string formatting to join them into the final message.
Computers and Technology
2 answers:
vova2212 [387]4 years ago
5 0

Answer:

def name_facts(firstname):

   print("Your name is",len(firstname),"letters long",end=", ")

   if(firstname[0] == 'A'):

       print("does start with the letter A",end=", ")

   else:

       print("does not start with the letter A", end=", ")

   if(firstname.count('Z')>0 or firstname.count('X')>0):

       print("and does not contain a Z or X")

   else:

       print("and does not contain a Z or X")

#Testing

name_facts("Allegra")

name_facts("Xander")

Explanation:

azamat4 years ago
5 0

Answer:

// Comments are used for explanatory purpose

// Program starts here

#include<iostream>

using namespace std;

int main()

{

// Declare firstname

string firstname;

//Prompt to enter firstname

cout<<"What's your first name: ";

// Accept input

cin>>firstname;

// A. Get string's length

int length = firstname.length();

// Print length

cout<<"Length = "<<length<<endl;

// Copy string to chat array

char char_array[length + 1];

// copying the contents of the string to char array

strcpy(char_array, firstname.c_str());

// B. Check if it starts with letter A

if(char_array[0] == 'A')

{

cout<<"Your Firstname begins with letter A"<<endl;

}

else

{

cout<<"Your Firstname doesn't begin with letter A"<<endl;

}

// Check if it contains X or Z

int k = 0;

for (int i = 0; i < n; i++) {

if(char_array[i] == 'Z' || char_array[i] == 'X')

{

k++;

}

if(k == 0)

{cout<<"Your Firstname doesn't contain Z or X";}

else

{cout<<"Your Firstname contains Z or X";}

}

return 0;

}

You might be interested in
To narrow the search for consumers, search engines used to measure the relevance of a website or an information page by counting
noname [10]
The answer is : it was easily manipulated.   To narrow the search for consumers, search engines used to measure the relevance of a website or an information page by counting the number of times the searched words appeared on that web page or document.  They don't use this criterion anymore because it was easily manipulated.
5 0
3 years ago
The algorithm ____ is used to find the elements in one range of elements that do not appear in another range of elements.
Musya8 [376]

Answer:

A. set_union

Explanation:

The algorithm set_union is used to find the elements in one range of elements that do not appear in another range of elements.

4 0
3 years ago
Why do we need to update database regularly
sergiy2304 [10]
To protect from attackers gaining access by sitting on a certain configuration too long. 
7 0
3 years ago
What is the numeric range of a 16-bit twos complement value? A 16-bit excess notation value? A 16-bit unsigned binary value?
blagie [28]

Answer:

twos complement value is (-2^15 -1) -32768 to 32767.

excess notation value is -32768 to 32767.

unsigned binary value is (2^16) 0 to 65535

Explanation:

Excess notation: used to represent signed integers. Always uses fixed number of bits with leftmost representing the sign.

Twos complement notation: As opposed to excess notation, a sign bit of 0 is used to represent the non-negative (+) sign and a 1 for the negative (-); again, zero is included in the non-negative set.

Unsigned Binary values: are binary values/bits that don't have signs

7 0
4 years ago
Select all the lines that have a slope of 5/2
sweet-ann [11.9K]

Answer:

Add a picture, then ask the question again.

5 0
3 years ago
Other questions:
  • Information gathered from observing a plant grow 3 cm over a two-week period results in _______.a. inferences. b. variables. c.
    11·1 answer
  • The figure above shows two pith balls suspended by threads from a support. In the figure, A. the pith balls are uncharged. B. pi
    13·2 answers
  • Project management software helps you develop a ______________, which serves as a basis for creating Gantt charts, assigning res
    15·1 answer
  • Differences between the first four generations of computers​
    12·1 answer
  • The gene form of a trait is called a(n) ​
    10·1 answer
  • Please help it’s timed
    11·1 answer
  • Help ASAP please This is a skills lab simulation for college, it’s on Microsoft word is there a keyboard shortcut or something o
    12·1 answer
  • When is the POST process executed?
    14·1 answer
  • The History feature of a browser enables you to retrace your browsing history over a short period of time. (1 point) True False
    9·1 answer
  • When formulating a linear programming model on a spreadsheet, the decisions to be made are located in the data cells.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!