# Program 1
# input a string from user
s1=input("Enter a string:")
# print the length of the string
print("Length of the string = ",len(s1))
# print first character of the string
print("First character of the string = ",s1[0])
# print the last character of the string
print("Last character of the string = ",s1[-1])
# Program 2
# Create an empty list
mylist=[]
# input 5 float numbers
for i in range(5):
num=float(input())
mylist.append(num)
# print the sum of the list elements
print("Sum = ",sum(mylist))
# print the minimum element
print("Minimum element = ",min(mylist))
# print the maximum element
print("Maximum element = ",max(mylist))
# print the average of the list elements
print("Average = ",sum(mylist)/len(mylist))
# remove the last element of the list
mylist=mylist[:-1]
# print the list
print("Mylist = ",mylist)
3. Write Python statements that will do the following: a) Input a string from the user....
Write a program(Python language for the following three questions), with comments, to do the following: Ask the user to enter an alphabetic string and assign the input to a variable str1. Print str1. Check if str1 is valid, i.e. consists of only alphabetic characters. If str1 is valid Print “<str1> is a valid string.” If the first character of str1 is uppercase, print the entire string in uppercase, with a suitable message. If the first character of str1 is...
Python installation: Install Python 3 as described here. (We will work with Windows PC's.) Launch IDLE Enter the program listed in the attached file: "First program in IDLE". Save a "ProgA.py" Debug until code runs correctly. Take a screenshot of the correct output Save as "YourLastName_IDLE1.png" Upload here How do you debug # First Python Program #Fill date here # Name: Fill name here # _________________________ first = input("Enter first name:") last = input("Enter last name:") print("Hello " + first...
Write a Python program, with comments, to do the following: Ask the user to enter a string with at least 7 characters. Assume user will enter a valid string. Assign the string to a variable str1 and print str1. In a loop do the following: Update the value of str1 so that the first character from the current value of str1 is removed and added to the end. Print the updated str1. The loop should continue until updated...
Using python 1. Write a program that read a line of input as a string and print every second character of the string
Write a Python script in that will prompt the user to enter a string. After the user enters their string print its length and the ordinal value of the first, third, and seventh character. Assume the input will be of sufficient length. Use "nice" input and output
5. Write a new function called "listinsert" based on the following IPO # function: listinsert # INPUT: a list, a location (integer) and a data # element (can be a string, float, Boolean or # int) # PROCESSING: inserts the supplied data element into the # list at the desired location # OUTPUT: return a new copy of the list that contains # the inserted element Make sure that you DO NOT use any list methods, such as the "insert"...
Please do it with C++. Thanks:) Write a program that reads a string and a character from the keyboard. The program should output how many times the character appears in the string. Make the program run in a loop until the string finish is input. Sample run: Input a string: alicia Input a letter: a The letter appears 2 times Input a string: felix Input a letter: x The letter appears 1 time Input a string: finish Good Bye.
Write a C++ program to get an input string from the user, and output the string in uppercase letters. Use a dynamic character array to store the string. ?(this can be from any input file, there is no specific file.)
Write code in python for following Use queue to implement it Implement a decryption method String decrpt(String s) to decrypt a number sequence (stored in a string s). The decryption algorithm works as follows: Delete the first element of the sequence Move the first element of the sequence to the end Delete the first element of the sequence Move the first element of the sequence to the end …. This process keeps running until all element in the sequence has...
LANGUAGE = C i. Write a program that takes int numbers from user until user gives a sentinel value (loop terminating condition). Sort the numbers in ascending order using Insertion sort method. Sorting part should be done in different function named insertionSort(). Your code should count the number of swaps required to sort the numbers. Print the sorted list and total number of swaps that was required to sort those numbers. (4 marks) ii. In this part take another number...