Answer:
A statement in Visual Basic is a complete instruction. It can contain keywords, operators, variables, constants, and expressions. Each statement belongs to one of the following three categories: Declaration statements, which name a variable, constant, or procedure and can also specify a data type.
Answer:
None of the options is correct.
Explanation:
One of the simplest statements that you can write in Python is a print statement, which causes a message to be displayed on the screen. For example, the following statement causes the message Python programming is fun! to be displayed:
print 'Python programming is fun!'
Notice that after the word print, the Python programming is fun! was written inside a set of single-quote marks. The quote marks are necessary, but they will not be displayed. They simply mark the beginning and the end of the text that we wish to display.
Here is an example of how you would type this print statement at the interpreter’s
prompt:
>>> print 'Python programming is fun!'
After typing the statement you press the Enter key and the Python interpreter executes the statement, as shown here:
>>> print 'Python programming is fun!'
Python programming is fun!
>>>
Thus, the correct way to write the codes in the question is:
print 'Programming is fun'
print 'Python'
print 'Computer Science'
Create a function generateString(char, val) that returns a string with val number of char characters concatenated together. For example generateString('a', 7) will return aaaaaaa. Additionally create the code to run your function and print out the new string.
Explanation:
<u>CODE :</u>
import sys
import random
character= sys.argv[1]
count= int(sys.argv[2])
def generateString('char', count):
random = char * count
return random
print(character*count)
<u>OUTPUT :</u>
In the above code, you are accepting a character, and a count value to go with it. When the value is updated, character is multiplied with the count, and the output is generated accordingly
Answer:
#Section 1
lst= []
lstNo=int(input("Enter even number of elements in List: "))
for i in range(0, lstNo):
pr=int(input(": " ))
lst.append(pr)
print(lst)
#Section 2
nlst=[]
dlst=[]
n =len(lst)
i=0
while (i < n/2):
nlst.append(lst[i])
i = i+1
j = n-1
while j >= n/2:
dlst.append(lst[j])
j = j-1
dlst.sort()
for a in range(len(dlst)):
nlst.append(dlst[a])
print(nlst)
Explanation:
#section 1:
An empty list is declared to hold the list inputs by the user <em>lst= []
</em>
The program then prompts the user to enter an even number of elements that will be contained in the list.
The for loop is used to iterate from zero(0) to the number of elements stated, in order to get the input that is appended to the list.
lastly, the list is printed out.
#Section 2:
In this section two new lists are created to hold one half of the value respectively.
The first list collects the first half of the list using a while loop and stores it, it does not perform any sorting on it.
The second list collects the second half using a while loop and sorts the list using the<em> .sort() </em>method which arranges elements in an ascending order.
Finally, the second list that has been sorted is added to the first and the result is printed to the screen.
A picture of how the code will run has been attached.