Given a string s with even length, write an expression to return the first half of the string. (in python3)
answer)
s=input("Enter a string s with even length: ")
length=int(len(s)/2)
if(len(s)%2==0):
print(s[0:length])
else:
print("String length is not even")
output:

Given a string s with even length, write an expression to return the first half of...
Write a context-free grammar for the language where all strings are of even length and the first half of the string is all 0’s, but it must be an odd number of 0’s
Python3 : Write the function longestRun(s, chars) that takes a possibly-empty string s and a second possibly-empty string of chars. We will say that a character is "good" if it is in the chars string (case insensitively, so "A" and "a" would match). The function should return the length of the longest consecutive run of good characters in the given string s. For example, consider: longestRun("abbcazBbcababb","bz"). This returns 3 (look for "zBb"). Restrictions: for loop, slicing cannot be used, if...
Add or Subtract. Write a function (add-sub-string s). The function consumes a Str of even length, where every even- numbered character is either "+" or "-", and odd-valued characters are numeric The function should add up all the digits that follow a "+", and subtract all the digits that follow a "-". For example, (add-sub-string "+3+4-5") => 2 (add-sub-string "-5+3+4-6-6") - 10 => The interface file contains the function char->nat that converts a numeric Char to the corresponding numeric value....
Write a function that can return the length of a string in C language. Please leave comments to explain the code and verify that it runs properly... Example: Input String: China The length of the string is 5. #include <stdio.h> int length(char * p) { /write your code here } main(){ int len; char str[20]; printf("Input string:"); scanf("%s", str); len = length(str); printf("The length of string is %d. ", len); getchar(); ...
Given a String variable address, write a String expression consisting of the string "http://" concatenated with the variable's String value. So, if the variable refers to "www.turingscraft.com", the value of the expression would be "http://www.turingscraft.com". In python please
Write a program that prompts a user for an input string of length at least two and prints the string with the first half in upper case and the second half in lower case. If the length of the string is odd, the "second half" should be one character longer than the "first half". Show Hint
Define a python function even(string) that accepts a python string of any length and returns a new string made of just the characters with even indexes For example even('Final exam') should return a string 'Fnlea'.
In Python3 write a function, given a string, compute recursively the number of times lowercase "hi" appears in the string,.
1) Write a method that will return the length of smallest string in an array of strings. smallestLength ({“hola”, “word”, “night”, “boom”}) → 4 smallestLength ({“java”, “is”, “so”, “much”, “fun”}) → 2 smallestLength ({“i”, “love”, “java”}) → 1 //precondition: strs.length>0 public static int smallestLength(String[] strs) { }