Question

I need help writing a very basic code in python. The code should not be very...

I need help writing a very basic code in python. The code should not be very complicated. The code must have the following things in it:

1. create a function that takes a state and length of characters and makes a license plate and use the function to make a plate based on user input (use the def function and random.choice as well as import random)
2. the license plate should be a mix of random letters and numbers based on the length

What it should look like:

Input state:
CA
Input character amount:
9
CA-A14J2T5HP
Would you like another one?
yes (restarts code if yes)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#source code:

import random
def licence_plate(state,length):
   lst=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",0,1,2,3,4,5,6,7,8,9]
   plate=""
   for i in range(length):
       plate=plate+str(random.choice(lst))
   return state+"-"+plate
while(True):
   a=input("Enter State:")
   b=int(input("Enter character amount:"))
   print(licence_plate(a,b))
   check=input("Would you like another one yes/no?")
   if(check=="yes"):
       continue
   else:
       break

#output:

#if you have any doubt comment below..if you like give thumbs up..

Add a comment
Know the answer?
Add Answer to:
I need help writing a very basic code in python. The code should not be very...
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
  • PLEASE CODE IN PYTHON Run-length encoding is a simple compression scheme best used when a data-set...

    PLEASE CODE IN PYTHON Run-length encoding is a simple compression scheme best used when a data-set consists primarily of numerous, long runs of repeated characters. For example, AAAAAAAAAA is a run of 10 A’s. We could encode this run using a notation like *A10, where the * is a special flag character that indicates a run, A is the symbol in the run, and 10 is the length of the run. As another example, the string KKKKKKKKKKKKKBCCDDDDDDDDDDDDDDDKKKKKMNUUUGGGGG would be encoded...

  • i need python code, thank you very much! characters) and prints ) 3. Write function, smallestCharacterLargerThan(keyChar,...

    i need python code, thank you very much! characters) and prints ) 3. Write function, smallestCharacterLargerThan(keyChar, inputString) that takes as input key character, keyChar, and a string of one or more letters (and no other the "smallest" character in the string that is larger than keyChar, where one character is smaller than another if it occurs earlier in the alphabet (thus 'C is smaller than 'y' and both are larger than 'B') and 2) the index of the final occurrence...

  • Write a Python Code for a Function: you need to come up with code for shift_char....

    Write a Python Code for a Function: you need to come up with code for shift_char. Write the code in a way in which you can shift the character by writing the number of shifts. Use the ASCII code for this. For example in lie 11, the input for char_to shift is r. U shift it by 1 so it becomes s. below is the function def shift_char(char_to_shift, amount_to_shift): ''' shifts any character by moving it a certain amount on...

  • Python 3 Modify the sentence-generator program of Case Study so that it inputs its vocabulary from...

    Python 3 Modify the sentence-generator program of Case Study so that it inputs its vocabulary from a set of text files at startup. The filenames are nouns.txt, verbs. txt, articles.txt, and prepositions.txt. (HINT: Define a single new function, getWords. This function should expect a filename as an argument. The function should open an input file with this name, define a temporary list, read words from the file, and add them to the list. The function should then convert the list...

  • I need help in Python. This is a two step problem So I have the code...

    I need help in Python. This is a two step problem So I have the code down, but I am missing some requirements that I am stuck on. Also, I need help verifying the problem is correct.:) 7. Random Number File Writer Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500. The application should let the user specify how many random numbers the file...

  • Python Problem Hello i am trying to finish this code it does not save guesses or...

    Python Problem Hello i am trying to finish this code it does not save guesses or count wrong guesses. When printing hman it needs to only show _ and letters together. For example if the word is amazing and guess=a it must print a_a_ _ _ _ not a_ _ _ _ and _a_ _ _ separately or with spaces. The guess has a maximum of 8 wrong guesses so for every wrong guess the game must count it if...

  • Please help with writing this code. The language is C++. I'm using vim. Thanks Problem Statement...

    Please help with writing this code. The language is C++. I'm using vim. Thanks Problem Statement A good password has many requirements. Humans have a hard time meeting these requirements left to their own devices. You are tasked with creating a program that will generate a password based on what the user wants in the password The user should be able to choose if they want a password with: letters upper case "lower case *numbers The user should also provide...

  • Need help writing this code in python. This what I have so far. def display_menu(): print("======================================================================")...

    Need help writing this code in python. This what I have so far. def display_menu(): print("======================================================================") print(" Baseball Team Manager") print("MENU OPTIONS") print("1 - Calculate batting average") print("2 - Exit program") print("=====================================================================")    def convert_bat(): option = int(input("Menu option: ")) while option!=2: if option ==1: print("Calculate batting average...") num_at_bats = int(input("Enter official number of at bats: ")) num_hits = int(input("Enter number of hits: ")) average = num_hits/num_at_bats print("batting average: ", average) elif option !=1 and option !=2: print("Not a valid...

  • Python code define a function car that takes 'swift' as a parameter function should count how...

    Python code define a function car that takes 'swift' as a parameter function should count how many letters in the string function should return a dictionary where key is lower case alpha caracter and value is the number of times that character appears in sentence. ex- input- that big car is so expensive output- 't':1, 'h':1, 'a':2, 'b':1, 'i':3,......

  • I am writing python code. I submitted an assignment but the professor said it was a...

    I am writing python code. I submitted an assignment but the professor said it was a modularization. Can you help me see what part of the code is modularization? Pseudocode: 1. Decalre MainMethod () function: # A. Parameters: Three numbers # B. Put the three numbers in reverse # 2. Main Program # A. Initialize Varibles # B. Accepts three values from the user # C. Invoke MainMethod () function, passing the three numbers as arguments in reverse # D....

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