Question

In: Computer Science

PYTHON Write a program for an event organizer. The code can be as short as 7...

PYTHON

Write a program for an event organizer. The code can be as short as 7 lines; 9 lines are good enough!

a) Request the organizer to enter a participant’s full name in a single input. The input can take two different formats: i. l_name, f_name [1.5 pts] ii. f_name l_name [1.5 pts] b) Print a customized greeting message using the first name, regardless of the formats: “Dear f_name, welcome to the party!” with only the 1 st letter of f_name in upper case.

Hint 1: Try to work on one form, at a time. After figuring out how to do both, add an if statement.

Hint 2: Just need to use in, len(), .find() and, of course, input().

Solutions

Expert Solution


code:

# Taking full name as one string
s = input("Enter string: ")

# checking whether "," is in string
if "," in s:
    ind = s.find(",") # finding index of "," in string
    f_name = s[(ind+1):len(s)] # Then first name is from comma index to last index
else:
    ind = s.find(" ")
    f_name = s[0:ind]
  
# Printing the output string
print("Dear "+f_name+", welcome to the party!")

# They are only 8 lines in the program and i have used only .find(), in

OUTPUT


Related Solutions

Please write in beginner level PYTHON code! Your job is to write a Python program that...
Please write in beginner level PYTHON code! Your job is to write a Python program that asks the user to make one of two choices: destruct or construct. - If the user chooses to destruct, prompt them for an alternade, and then output the 2 words from that alternade. - If the user chooses construct, prompt them for 2 words, and then output the alternade that would have produced those words. - You must enforce that the users enter real...
Use python programming to write this code and provide a screen short for the code. 2....
Use python programming to write this code and provide a screen short for the code. 2. Write a function that takes one argument (a string) and returns a string consisting of the single character from that string with the largest value. Your function should contain a for loop. You can assume that the input to your function will always be a valid string consisting of at least one character. You can assume that the string will consist only of lower-case...
please answer this in a simple python code 1. Write a Python program to construct the...
please answer this in a simple python code 1. Write a Python program to construct the following pattern (with alphabets in the reverse order). It will print the following if input is 5 that is, print z one time, y two times … v five times. The maximum value of n is 26. z yy xxx wwww vvvvvv
As the event organizer, one of your primary responsibilities will be to ensure that your event...
As the event organizer, one of your primary responsibilities will be to ensure that your event gets off to a good start. Typically, events begin by welcoming participants and spectators and thanking the local community, sponsors, and volunteers for the role, they are playing in the event. Post the opening remarks you could use to launch the event. Provide your peers with feedback about their opening remarks including additions they could make to their remarks along with comments about ways...
Please write in Python code Write a program that stores the following data in a tuple:...
Please write in Python code Write a program that stores the following data in a tuple: 54,76,32,14,29,12,64,97,50,86,43,12 The program needs to display a menu to the user, with the following 4 options: 1 – Display minimum 2 – Display maximum 3 – Display total 4 – Display average 5 – Quit Make your program loop back to this menu until the user chooses option 5. Write code for all 4 other menu choices
CODE IN PYTHON 1. Write a program that asks the user for the number of slices...
CODE IN PYTHON 1. Write a program that asks the user for the number of slices of pizza they want to order and displays the total number of dollar bills they owe given pizza costs 3 dollars a slice.  Note: You may print the value an integer value. 2. Assume that y, a and b have already been defined, display the value of x: x =   ya+b    3. The variable start_tees refers to the number of UD T-shirts at the start...
Write a program function code in Python that prompts the user to enter the total of...
Write a program function code in Python that prompts the user to enter the total of his/her purchase and add 5% as the VAT. The program should display the total without and with VAT. ( that mean i should ask the user to enter the number of their item " so i think that i should use range" then print the result with and without the VAT )
Please write in Python code please: Write a program that asks the user to enter 5...
Please write in Python code please: Write a program that asks the user to enter 5 test scores between 0 and 100. The program should display a letter grade for each score and the average test score. You will need to write the following functions, including main: calc_average – The function should accept a list of 5 test scores as an input argument, and return the average of the scores determine_grade – The function should accept a test score as...
Write a program IN PYTHON of the JUPYTER NOOTBOOK Write a Python program that gets a...
Write a program IN PYTHON of the JUPYTER NOOTBOOK Write a Python program that gets a numeric grade (on a scale of 0-100) from the user and convert it to a letter grade based on the following table. A: 90% - 100% B 80% - 89% C 70% - 79% D 60% - 69% F <60% The program should be written so that if the user entered either a non-numeric input or a numeric input out of the 0-100 range,...
Python program. Write a python program that can convert any radix-d (arbitrary base) number to the...
Python program. Write a python program that can convert any radix-d (arbitrary base) number to the equivalent radix-e (another arbitrary base) number. Where e and d are members in [2, 16]. Remember, base 16 needs to be calculated as hexadecimal. So, if radix-d is input as a hexadecimal number, it needs to convert and output to desired base. Conversely, if base 16 is the desired output, then the output needs to show a hexadecimal number. Hints: The easiest approach is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT