Question

PYTHON script for the following things: Creates a variable and stores a string value that is...

PYTHON script for the following things:

  1. Creates a variable and stores a string value that is at least 8 characters long.
  2. Displays the value of the variable to the screen.
  3. Displays the length of the string using the len() function.
  4. Displays the last 3 characters of the string by using the substring() function.
  5. Creates a list containing 8 elements (numbers or strings) and displays the list using the print() function.

Homework Answers

Answer #1
# Creates a variable and stores a string value that is at least 8 characters long.
s = "This is my string"

# Displays the value of the variable to the screen.
print(s)

# Displays the length of the string using the len() function.
print(len(s))

# Displays the last 3 characters of the string by using the substring() function.
print(s[-3:])

# Creates a list containing 8 elements (numbers or strings) and displays the list using the print() function.
lst = [1,"two",3,"four","five",6,7,"eight"]
print(lst)

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
Perl Programming Language 1) Write a Perl script to concatenate "This is String One" and "This...
Perl Programming Language 1) Write a Perl script to concatenate "This is String One" and "This is String Two". Print all three strings, one per line with its length. Output: This is String One (print length here) This is String Two (print length here) This is String One This is String Two (print length here) 2) Write a Perl function that creates an array using qw function with the month names. It then prints the elements 4 and 7 (May...
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...
Using Python Assigns the value “Phil” to the variable SomeName. Uses the len function and the...
Using Python Assigns the value “Phil” to the variable SomeName. Uses the len function and the SomeName variable to assign the number of letters in Phil’s name to the variable NameLength. Outputs the following using a print statement (the print statement should output the quotation marks and the values of the SomeName and NameLength variables where indicated by the [brackets]): “I very much enjoy infinite loops,” said [value of SomeName], whose name is [value of NameLength] letters long. Use placeholders...
This is an intro to Python question: #Write a function called linear() that takes two parameters...
This is an intro to Python question: #Write a function called linear() that takes two parameters #- a list of strings and a string. Write this function so #that it returns the first index at which the string is #found within the list if the string is found, or False if #it is not found. You do not need to worry about searching #for the search string inside the individual strings within #the list: for example, linear(["bobby", "fred"], "bob") #should...
** Language Used : Python ** PART 2 : Create a list of unique words This...
** Language Used : Python ** PART 2 : Create a list of unique words This part of the project involves creating a function that will manage a List of unique strings. The function is passed a string and a list as arguments. It passes a list back. The function to add a word to a List if word does not exist in the List. If the word does exist in the List, the function does nothing. Create a test...
Use Python to Complete the following on a single text file and submit your code and...
Use Python to Complete the following on a single text file and submit your code and your output as separate documents. For each problem create the necessary list objects and write code to perform the following examples: Sum all the items in a list. Multiply all the items in a list. Get the largest number from a list. Get the smallest number from a list. Remove duplicates from a list. Check a list is empty or not. Clone or copy...
Module 4 Assignment 1: Pseudocode & Python with Variable Scope Overview Module 4 Assignment 1 features...
Module 4 Assignment 1: Pseudocode & Python with Variable Scope Overview Module 4 Assignment 1 features the design of a calculator program using pseudocode and a Python program that uses a list and functions with variable scope to add, subtract, multiply, and divide. Open the M4Lab1ii.py program in IDLE and save it as M4Lab1ii.py with your initials instead of ii. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and...
PYTHON : Create a Email Address Parser (* Please do make comments*) Often times, you may...
PYTHON : Create a Email Address Parser (* Please do make comments*) Often times, you may be given a list of raw email addresses and be asked to generate meaningful information from such a list. This project involves parsing such a list and generating names and summary information from that list. The script, eparser.py, should: Open the file specified as the first argument to the script (see below) Read the file one line at a time (i.e., for line in...
Bash script with branching and looping Part 1: 1. Create a variable called NAME and set...
Bash script with branching and looping Part 1: 1. Create a variable called NAME and set it equal to the empty string (NAME=””). Create a variable called NAME_LENGTH and set it equal to the length of your last name. Output the value of the NAME variable to show that it is empty. 2. Write a FOR loop that executes as many times as there are letters in your name (use the NAME_LENGTH variable in your condition). Use a CASE statement...
write a code in python Write the following functions below based on their comments. Note Pass...
write a code in python Write the following functions below based on their comments. Note Pass is a key word you can use to have a function the does not do anything. You are only allowed to use what was discussed in the lectures, labs and assignments, and there is no need to import any libraries. #!/usr/bin/python3 #(1 Mark) This function will take in a string of digits and check to see if all the digits in the string are...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT