Question

Python short one to three line answers 45 a. Write a conditional that multiplies the value...

Python short one to three line answers

45 a. Write a conditional that multiplies the value assigned to pay by one-and-a-half if worked_overtime contains the value True.

b. Assume that c is a variable that has been given a string value. Write an expression whose value is True if and only if c is NOT what is called a whitespace character(space,tab, or newline)

c. Assume that c is a variable that has been given a string value. Write an expression whose value is True if and only if c is what is called a whitespace character(space,tab, or newline)

Homework Answers

Answer #1

Q45)

a) For The Conditional statement we have first check whether worked_overtime is true of not and if it is true then pay = pay *1.5

In Python We use a IF statement to do this

Expression will be : if worked_overtime == True : pay *= 1.5

Here we have used == ( equals operator ) that check true for worked_overtime and if true then pay*=1.5 is same as pay = pay * 1.5

b) If c is then it should be white space , newline character , tab .

So in the expression we will check three things 1. c is white space 2. c is newline 3. c is tab and we combine them using or operator and if anyone one gets true then value is false by negating it and if any condition is not true then true will be the value

Expression will be : !(c == ' ' or c== '\n' or c == '\t')

In Python ' ' means White space , '\n' means newline , '\t' means tab so we use == ( equals operator ) to compare each and we have negate( ! ) the output of inner bracket .

c) In this we have do the Opposite of what we did in Last Part b

So in the expression we will again check three things 1. c is white space 2. c is newline 3. c is tab and we combine them using or operator and if anyone one gets true then value is true .

Expression will be : (c == ' ' or c== '\n' or c == '\t')

Here we just remove the Negation operator and we get the desired expression

This is how we can write all three expression in one line in Python for each part

Thank You

If u like the answer then do Upvote it and have any doubt ask in comments

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
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...
solve in python 3.8 please The question is about Strings Modify your function so that it...
solve in python 3.8 please The question is about Strings Modify your function so that it can handle the following two situations: The string given as an argument has no characters. In this case, you should return the empty string. The string given as an argument has one character. In this case, you should return the one-character string given to you. Without any consideration for these cases, your function probably causes an error or returns the wrong result in the...
Python #Write a function called are_anagrams. The function should #have two parameters, a pair of strings....
Python #Write a function called are_anagrams. The function should #have two parameters, a pair of strings. The function should #return True if the strings are anagrams of one another, #False if they are not. # #Two strings are considered anagrams if they have only the #same letters, as well as the same count of each letter. For #this problem, you should ignore spaces and capitalization. # #So, for us: "Elvis" and "Lives" would be considered #anagrams. So would "Eleven plus...
in the scheme programming language implement a game of rock paper scissors between a user and...
in the scheme programming language implement a game of rock paper scissors between a user and the computer. Only the following scheme subsets should be used: Special symbols (not case sensitive in our version (R5RS), but is in R6RS): a. Boolean: #t (else) and #f b. Characters: #\a, #\b ... #\Z c. Strings: in double quotes 3. Basic functions: a. quote b. car c. cdr d. c _ _ _ _ r, where each _ is either “a” or “d”...
#Write a function called has_a_vowel. has_a_vowel should have #one parameter, a string. It should return True...
#Write a function called has_a_vowel. has_a_vowel should have #one parameter, a string. It should return True if the string #has any vowels in it, False if it does not. def has_a_vowel(a_str): print("Starting...") for letter in a_str: print("Checking", letter) if letter in "aeiou": print(letter, "is a vowel, returning True") return True else: print(letter, "is not a vowel, returning False") return False print("Done!")       #Below are some lines of code that will test your function. #You can change the value of...
Java Please [(1)] A palindrome is a string that reads the same forwards as backwards. Using...
Java Please [(1)] A palindrome is a string that reads the same forwards as backwards. Using only a fixed number of stacks and queues, the stack and queue ADT functions, and a fixed number of int and char variables, write an algorithm to determine if a string is a palindrome. Assume that the string is read from standard input one character at a time. The algorithm should output true or false as appropriate [(2)] Let Q be a non-empty queue,...
Write a program that reads in a line consisting of a student’s name, Social Security number,...
Write a program that reads in a line consisting of a student’s name, Social Security number, user ID, and password. The program outputs the string in which all the digits of the Social Security number and all the characters in the password are replaced by x. (The Social Security number is in the form 000-00-0000, and the user ID and the password do not contain any spaces.) Your program should not use the operator [] to access a string element....
Write a program which inputs an integer value, incr, from the user at the keyboard, and...
Write a program which inputs an integer value, incr, from the user at the keyboard, and then displays a graph of the sine of the degree values from 0 to 180, in increments of incr. You must use the sin function (in a similar manner to ceil and floor) to find the sine. Note that the sin function only operates on radians so the degree value must first be converted to radians. To do so, multiply the degree value by...
Using python, write the program below. Program Specifications: You are to write the source code and...
Using python, write the program below. Program Specifications: You are to write the source code and design tool for the following specification: A student enters an assignment score (as a floating-point value). The assignment score must be between 0 and 100. The program will enforce the domain of an assignment score. Once the score has been validated, the program will display the score followed by the appropriate letter grade (assume a 10-point grading scale). The score will be displayed as...
Arrays, loops, functions: Lotto Element Repeated Function Write a function that that takes as parameters an...
Arrays, loops, functions: Lotto Element Repeated Function Write a function that that takes as parameters an array of ints, an int value named element, and an int value named end. Return a bool based on whether the element appears in the array starting from index 0 and up to but not including the end index. Generate Random Array Write a function that takes as parameters an array of integers and another integer for the size of the array. Create a...