Question: 1. (5 pts) Translate the following formula into a python arithmetic expression: (as + b) 7 6-8cd 2. (5 pts) Assume that you have
1. (5 pts) Translate the following formula into a python arithmetic expression: (as + b) 7 6-8cd 2. (5 pts) Assume that you have a variable called myString that has been assigned a string value at least 9 characters long. Write a print statement that will print out the fourth character and the seventh character in myString using indexes. This is just one print statement, and there are two things to print - each of the characters mentioned. 3. (5 pts) Write a single expression whose value is True only when the value of a variable called y is an even number that is larger than O. NO need to initialize any variables, assume y has been assigned an integer value. You must use relational/comparison and/or Boolean operators to solve this problem. 4. (5 pts) Write a SINGLE Python statement that will input a value, convert it to an integer and assign the value to a variable called val. 5. (5 pts) Translate the binary number 100111 into decimal. You must show your work in order to get credit for this problem. 7. (a) (4) Write an example of a list literal that contains two items. One of these items should be a string literal and the other one should be a list literal containing three items - a floating point number, an int, and a string literal. (b) (2) What is the length of the list you wrote down for part (a)- figure it out by hand. 8. (9) Evaluate each of the following python expressions and write its value (a) 6%9 (b) 5//3 (c) 6/2 9. (10) Assume you have input three unique (they all have different values) values into variables named x, y, and z. Write one or more if statements in python that determine and print the value of the largest of these three. NO using lists, built-in functions like max(), etc. You must do this "by hand", you must compare these variables using binary relational operators. That just means you are comparing two values at a time, like x > y. Do not use the three part comparison operator! 10. (10) Write a while loop that runs 6 times. Each time input a word. If the word starts with a vowel (the vowels are a, e, I, o, u, and A, E, I, O, U) the print 'V', if not print 'C'. 11. (10) Write a while loop that inputs numbers from a user until they type the number 0. They should be read in as integers. Print the numbers out that you read in, and count how many numbers the user types. Print out the number of numbers the user typed after the loop ends.
Step by Step Solution
3.43 Rating (153 Votes )
There are 3 Steps involved in it
1 Python arithmetic expression for the given formula python result a 5 b 2 7 6 8 c d 2 Printing t... View full answer
Get step-by-step solutions from verified subject matter experts
