Question

1. Write a Python function username that prints a username consisting of the first initial of...

1. Write a Python function username that prints a username consisting of the first initial of the user's first name, followed by the user's last name. The function should produce the output shown when invoked with username(), depending on the user's input. Make sure the output of your code conforms to the specified layout exactly.

Please enter your first name (all lowercase): karen
Please enter your last name (all lowercase): huyck
Your username is khuyck.

2. Write a function letterGrade that takes a parameter grade and prints the grade with any plus (+) or minus (-) removed. It should perform exactly as follows for the invocation statements given. You should test your function with other invocation statements, as well.

letterGrade("B+")

Your grade is in the B range.

letterGrade("A-")

Your grade is in the A range.
1 0
Add a comment Improve this question Transcribed image text
Answer #1

1. Program:

#function name: username()
#parameters: none
#return value: none
def username():
#user input
fname = input( "Please enter your first name (all lowercase): ")
lname = input( "Please enter your last name (all lowercase): ")

#displaying username
print("Your username is:", fname[0]+lname)
  
  
username()

  

Sample Runs:

For indentation:

2. Program

#function name: letterGrade
#parameters: grade(string)
#return value: none
def letterGrade(grade):
if "+" in grade:
result = grade.strip("+")
else:
result = grade.strip("-")
  
print("Your grade is in the ", result ," range.")
  


#function call
letterGrade("B+")
letterGrade("A-")

  
  
Sample Run:

For Indentation:

Add a comment
Know the answer?
Add Answer to:
1. Write a Python function username that prints a username consisting of the first initial of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in python 5.23 Login Create a program that prompts the user for a username and password....

    in python 5.23 Login Create a program that prompts the user for a username and password. The correct username should be python and the correct password should be csci 135. See below for example output. (Different messages depending on if user name or password are correct.) Only allow the user to make 3 attempts. Welcome to my secret program! Please enter your username: Trish Please enter your password: Duce Invalid username and password Please enter your username: Trish Please enter...

  • In C++ write a complete and correct x++ program that generates student email addresses and prints...

    In C++ write a complete and correct x++ program that generates student email addresses and prints them to the screen based upon the data found in an input file, called students . txt. Each line of the space, followed by the student’s last name. Every email address is to be of the form [email protected]. In general, each username has four parts in this order: (i) the student; last name in lowercase letters; (ii) a number between 10- 99 generated at...

  • Using Python INST-FS-IAD-PROD.INS LAB1 Lab: Create User Account 2. get-password() #promt the user and create password, check the password fits the requirement USE the EXACT file names! Create a user...

    Using Python INST-FS-IAD-PROD.INS LAB1 Lab: Create User Account 2. get-password() #promt the user and create password, check the password fits the requirement USE the EXACT file names! Create a user login system. Your code should do the following: 3, create-user_name() #use this function to create the user name 1.Create your user database called "UD.txt", this should be in CSV format 4, write-file() #user this function to save the user name and password into "UD.txt" Deliverables: Sample: the data you saved...

  • Using Python Please Question 1: Pine Tree Write a program that, prints a 'pine tree' consisting...

    Using Python Please Question 1: Pine Tree Write a program that, prints a 'pine tree' consisting of triangles of increasing sizes, filled with a character (' oror '$' etc). Your program should consist of three functions: 1. A function print_shifted_triangle (n, m, symbol). It prints an n-line triangle, filled with symbol characters, shifted m spaces from the left margin. For example, if we call print_shifted_triangle (3, 4, +"), the expected output is: +++ Left margin +++++ 4 spaces 2. A...

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is sued. Write a Python...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is sued. Write a Python code that gets a string containing a person’s first, middle, and last name, and print her/his last name, followed by comma and the first name initial. For example, if the user enters Randy Rick Gomez, the program should display Gomez, R. Please note that in the output, the first character of each name should be capital. Please see the outcomes below: Outcome: Enter your...

  • Lab 3: Databased Admin Tool Python Objective: Develop an admin tool for username and password management. You will need...

    Lab 3: Databased Admin Tool Python Objective: Develop an admin tool for username and password management. You will need to use the best data structure to store the data you read from UD.txt for efficient processing. You can accomplish these tasks with Dictionary or List. The data file (UD.txt) : FIRST NAME, LAST NAME,USERNAME,PASSWORD Sam, DDal,sdd233,Pad231 Dave,Dcon,dcf987, BHYW4fw Dell,Grant,dgr803,Sb83d2d Mike,Kress,mkr212,UNNHS322 Lisa,Kate,lki065,dgw6234 Paul,Edward,ped332,9891ds Youyou,Tranten,ytr876,dsid21kk Nomi,Mhanken,nmh223,3282jd3d2 Write a program that imports the database from UD.txt Give the following options: A: Search by...

  • In C Write a function that asks for the user's first, middle, and last names. The...

    In C Write a function that asks for the user's first, middle, and last names. The names will be entered by the user on a single line and will be stored in three different C-strings. The program should then store, in a fourth array, the name arranged in the following manner: the last name followed by a comma and a space, followed by the first name and a space, followed by the middle name. For example, if the user entered...

  • Study guide Intro to PYTHON questions: 25) Write the code that will generate this output using...

    Study guide Intro to PYTHON questions: 25) Write the code that will generate this output using only while loops and if statements (no string multiplication). ###AAAAAAAA### ###BBBBBBBB### ###CCCCCCCC### ###AAAAAAAA### ###BBBBBBBB### ###CCCCCCCC### 26) Write code that asks the user for a size and prints a triangle of stars of that size that increases by two at each level. You can only use one while loop and any number of variables and counters you want, but you are limited to these tools....

  • Write a Python program to create userids: You work for a small company that keeps the...

    Write a Python program to create userids: You work for a small company that keeps the following information about its clients: • first name • last name • a user code assigned by your company. The information is stored in a file clients.txt with the information for each client on one line (last name first), with commas between the parts. In the clients.txt file is: Jones, Sally,00345 Lin,Nenya,00548 Fule,A,00000 Your job is to create a program assign usernames for a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT