Using Python
names = [‘Vernon’, ‘Cooper’, ‘Ronnie’, ‘Clay’]
if ‘Jordan’ not in names:
print(‘Cannot find Jordan.’)
else:
print(‘Jordan is a dog’)
print(names)
Solution:
Since names list does not contain element name as 'Jordan', therefore, if condition will satisfy and output will be printed as Cannot find Jordan.
Code:
# defining names list with names of
dogs
names = ['Vernon', 'Cooper', 'Ronnie', 'Clay']
# checking with if condition whether
Jordan is in names list or not
# since 'Jordan' is not present in names list of dogs, we will go
inside
# the if condition and execute the statement inside it.
if 'Jordan' not in names:
print('Cannot find Jordan.')
# this condition will not get executed
since if condition is satisfied.
else:
print('Jordan is a dog')
print(names)
Screenshot of Code:
Screenshot of output:
Using Python What will the following code display? names = [‘Vernon’, ‘Cooper’, ‘Ronnie’, ‘Clay’] if ‘Jordan’...
### Question in python code, write the code on the following program: def minmaxgrades(grades, names): """ Computes the minimum and maximujm grades from grades and creates a list of two student names: first name is the student with minimum grade and second name is the student with the maximum grade. grades: list of non-negative integers names: list of strings Returns: list of two strings """ def main(): """ Test cases for minmaxgrades() function """ input1 = [80, 75, 90, 85,...
Using Python The variables x and y refer to numbers. Write a code segment that prompts the user for an arithmetic operator and prints the value obtained by applying that operator to x and y. Using the following information run an example in Python Idle op = input("Enter an arithmetic operator: ") if op == "+": print(x + y) elif op == "-": print(x – y) elif op == "*": print(x * y) elif op == "/":...
Give the solution using Python programming for following with explanations: a. Take two numbers and display which number is positive and which number is negative. b. Take two numbers divide and display quotient and reminder. c. Take two numbers and check if they are same or not same. a. Write four differences between high level language and low level language? b. Write all the rules of naming any variables in python and provide at least one example for each rule?...
IN PYTHON: The following code contains syntax errors. Assuming the code should read in a name, and output a message indicating if the last name is "Smith". REWRITE THIS STATEMENT CORRECTLY. value = input(" enter your name using LAST, FIRST format") val= value.split(",") if value[0] ="Smith": print("your last name is common") else val[0] != "Smith": print("not so common") print(]"ODD")
What does the following code display? (Careful!) x = 0 word = 'hello' if word == 'Hello': x = x + 5 else: x = 17 print(x) A.0 B.5 C.17 D.22
Write a code in Python to print the following lines on the screen. Submit your code here, when it is completed. This is my first real project in Python. It seems very interesting and I cannot wait to learn more about it!
Using Python code. Fill in the gaps in the nametag function so that it uses the format method to return first_name and the first initial of last_name followed by a period. For example, nametag("Jane", "Smith") should return "Jane S." def nametag(first_name, last_name): return("___.".format(___)) print(nametag("Jane", "Smith")) # Should display "Jane S." print(nametag("Francesco", "Rinaldi")) # Should display "Francesco R." print(nametag("Jean-Luc", "Grand-Pierre")) # Should display "Jean-Luc G."
Without using lambda in PYTHON How can I find the word "Code" and "code" on a website and print how many times they appear?
Using python, write code for problem. Please also put screenshot
of your code.
The following program will perform properly if the user enters 0 in response to the request for input. However, the program will crash if the user responds with "eight". Rewrite the program using a try/except statement so that it will handle both types of responses. See Fig. 6.1. while True: n = int (input ("Enter a nonzero integer: ")) if n! = 0: reciprocal = 1/n print...
PYTHON:please display code in python
Part 1: Determining the Values for a Sine
Function
Write a Python program that displays and describes the equation
for plotting the sine function, then prompts the user for the
values A, B, C and D to be used in the calculation. Your program
should then compute and display the values for Amplitude, Range,
Frequency, Phase and Offset.
Example input/output for part 1:
Part 2: Displaying a Vertical Plot Header
A vertical plot of the...