Question

Wtite a Python script to print a range of alphabetic characters ‘a’ to ‘z’ using the...

Wtite a Python script to print a range of alphabetic characters ‘a’ to ‘z’ using the custom range() function. You will need to use the ASCII character value and then convert the ASCII value to a alphabetic letter using a chr() function.

Expected Output (submit code and output): Generate the characters from a to z, inclusive.

Homework Answers

Answer #1

The program is written python 3 .

using the for loop to print the ascii value of the characters. range() is used. It includes first number and excludes the second parameter. As we know in ASCII a-z is defined in 97-122. But we used 97-123 because 123 is excluded in range function.

And to print the number as character , used chr() function to represent it in alphabet or can say symbol as assigned to it in ascii format.

Here is the code

CODE:

#for loop to traverse through the ascii numbers of the alphabets
for i in range(97,123):
#it converts the number to the character and print it
print(chr(i), end=', ')

OUTPUT:

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,
Know the answer?
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
Similar Questions
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for an integer between 0 and 9999, inclusive. The script should then calculate the digit in each of the 1000’s, 100’s, 10’s, and 1’s place of the number. Create a variable for each of the 4 extracted digits. For example, if your variables are named nThousands, nHundreds, nTens, and nOnes, then, in the case of 9471, they would be end up being set to 9,...
PYTHON script for the following things: Creates a variable and stores a string value that is...
PYTHON script for the following things: Creates a variable and stores a string value that is at least 8 characters long. Displays the value of the variable to the screen. Displays the length of the string using the len() function. Displays the last 3 characters of the string by using the substring() function. Creates a list containing 8 elements (numbers or strings) and displays the list using the print() function.
Write a Python function that computes the frequency of characters in a string s. The function...
Write a Python function that computes the frequency of characters in a string s. The function should return a map where the key is the character and the value is the count. Make sure you include a main function and include comments to document your code.
Using Python: Create a code to generate 1001 values between 0 and 10 (essentially, start from...
Using Python: Create a code to generate 1001 values between 0 and 10 (essentially, start from 0 and use increment 0.01) and for each value ? ∈ [0,10] calculate sin(?) and the derivative of ?(x) = sin(?) using the central difference method: ????(?)/?? = ?(?+0.01)−?(?−0.01) 2∙0.01 . Output the result in a file using the print command: print (?, ???(?) , ????(?), ??? =′ ′, ??? =′\ ? ′ , ???? = ??) Recall that the output file must be...
Q1) Write a Python function partial_print, which takes one parameter, a string, and prints the first,...
Q1) Write a Python function partial_print, which takes one parameter, a string, and prints the first, third, fifth (and so on) characters of the strings, with each character both preceded and followed by the ^ symbol, and with a newline appearing after the last ^ symbol. The function returns no value; its goal is to print its output, but not to return it. Q2) Write a Python function called lines_of_code that takes a Path object as a parameter, which is...
Provide Python code that does the following: 4) Write a program that asks the user to...
Provide Python code that does the following: 4) Write a program that asks the user to enter a 9 character password. Test to see if it is a valid password. The validity test is a) they enter exactly 9 characters AND b) that every 3rd character, starting with the 1st character is the letter z. If it is valid print out the message “valid password” otherwise print the message “invalid password”. Sample output. Please enter a password: zaazbbz12 valid password...
Python coding: HW `declaration.py` * define function `calc_histogram(lines)` * returns histogram dictionary and total non-whitespace characters...
Python coding: HW `declaration.py` * define function `calc_histogram(lines)` * returns histogram dictionary and total non-whitespace characters * takes list of strings as argument * ignore comment lines denoted by `#` * if invoking script directly, load `data/declaration.txt` and calculate histogram * print histogram by sorted characters * count letter instances not characters, so `A` and `a` count as same (This is the local test I was given): if __name__ == '__main__': import os.path file_path = os.path.join("data", 'declaration.txt') print(file_path) letter =...
Write a script that will generate seven random integers in the range [-100:200] inclusive and then...
Write a script that will generate seven random integers in the range [-100:200] inclusive and then print the value of each integer and whether it is positive or negative and whether it is even or odd. An output from this program might be: -57 is negative and odd. 26 is positive and even. If zero is one of the random integers generated, remember that zero is even and neither negative or positive. Hint: even numbers are divisible by 2 with...
PLEASE HURRY, will upvote if correct python Write a method that prints characters using the following...
PLEASE HURRY, will upvote if correct python Write a method that prints characters using the following header: def printChars(ch1,ch2): this function prints out the characters between ch1 and ch2 inclusive. Assumption is that ch2 is always bigger than c1 and both lower cases. also Write a function that accepts a list as an argument and prints the number of occurrence of each item def itemOccurence(myList): i.e. input ("Hello",123, 342, 123, "Hello",123) output: 2 times "Hello" 3 times 123 1 time...
The prompt for the python script is this: Construct a 99% confidence interval for the proportion...
The prompt for the python script is this: Construct a 99% confidence interval for the proportion of days with solar power generation above 43 kWh for City A (cityA>43.0). In order to perform this function, you need to make the appropriate modifications to the provided script. In other words, you should: Replace ???DATASET_NAME??? with solarkwh Replace '???VARIABLE_NAME???' with the variable 'cityA' Replace ???Xvalue??? with the appropriate value The code they give us: print ('Confidence Interval - Step 4') n =...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT