What is the resulting data type

Assignment Help Python Programming
Reference no: EM133091466

Introduction to Python, Operators and Data Types

Exercise 1:  There are three main ways in which high-level source code can be converted into machine code suitable for running on a processor - Compilation, Pure Interpretation and Hybrid Implementation. In your own words, describe each of these different techniques and also rank them from fastest to slowest.

Exercise 2. Which of the above techniques does Python 3 use? Why do you think this might be? Do a spot of research if you're not sure!

Exercise 3. Give at least two examples of each of the following types of data:

Data Type

Example 1

Example 2

Integer

 

 

Boolean

 

 

Float

 

 

Double

 

 

String

 

 

Exercise 4. Provide the operator symbol for each of the following operators:

Operation

Symbol

Addition

 

Subtraction

 

Multiplication

 

Division (floating point)

 

Division (integer)

 

Modulus

 

Raise to a power

 

Equivalence

 

Not equal to

 

Assignment

 

Exercise 5. What is the resulting data type when we combine the following data types in the following ways.Try them out in the Python interpreter if you're not sure (some of them might surprise you), like this for example:
i = int(3)
f = float(4.0)
s = "five"
b = True
i_times_f = i * f
print(type(i_times_f), i_times_f) # float

First data type

Operation

Second data type

Resulting data type

Integer

Multiplied by

Float

Float

Integer

Multiplied by

Integer

 

Integer

Divided by

Integer

 

Integer

Integer-divided by

Integer

 

Float

Integer-divided by

Integer

 

String

Multiplied by

Integer

 

Integer

Multiplied by

String

 

Float

Divided by

Float

 

Float

Integer-divided by

Float

 

String

Added to

String

 

String

Subtracted from

String

 

Exercise 6. What data type is returned when we use Python 3's input function? Assuming the user entered a whole number, give an example of casting this data type into an integer.

Exercise 7. Write a small Python 3 script that asks the user to enter their birthday as three separate values (day, monthand year) and then prints out how old they are in the following format (for example):
If you were born on 18/01/1978 then that was day 18 of the year.
Use the format function to substitute values into your output. You can use the following snippet of code to calculate the day of the year:
import datetime as dt
date = dt.date(birth_year, birth_month, birth_day) # Create a date from user data
day_of_year = date.timetuple().tm_yday # Get day number from date
This code assumes that when you got the user's birthday details you stored them in variables called birth_day, birth_month and birth_year - if you didn't then either do so or substitute your own variable names into the date line (i.e. the middle line) above!

Exercise 8. Challenge Task - try this if you're feeling adventurous! You won't get any help with it, it's just to ‘stretch' you a little bit if you're finding all this too easy!
Write a program that outputs the lyrics to the classic love-song 99 Bottles of Beer On The Wall - using a loop!

The song's lyrics are as follows:
99 bottles of beer on the wall, 99 bottles of beer.
Take one down, pass it around, 98 bottles of beer on the wall...
The same verse is repeated, each time with one bottle fewer, until there are none left. On the very last verse when there are zero bottles left, the lyrics change to:
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall...
Whatever you do, don't type the lot in - it's a waste of your time and energy! Instead, use a loop (take a look at the range statement
You can cheat for the last verse if you like by putting it after the loop, or... you could use an if / else comparison if you go look ‘em up.
If you wanted the song to last a bit longer than the split-second it'll take for Python to output the entire lyrics, then put the following as the first line of your program:
import time
Then, somewhere in your loop add the following line so that it waits half a second between each iteration:
time.sleep(0.5)

It's quite possible to complete this entire task including the sleep-delay in less than 10 lines of code- so make Jay-Z proud!

Reference no: EM133091466

Questions Cloud

Social media impacted maslow hierarchy : How has Social Media impacted Maslow's (secondary) Hierarchy of needs? How has the hierarchy evolved post COVID-19 pandemic?
Explain the sources of power : Identify and explain the significance the following term (or phrase): Sources of power
How much basic federal tax will he save : Raymond, who is single, is enrolled in part-time studies. His net and taxable income is $49,500. How much basic federal tax will he save
What is csr benchmarking : Many companies use the strategy of benchmarking to compete within their respective industries in CSR policy, implementation, and effectiveness.
What is the resulting data type : What is the resulting data type when we combine the following data types in the following ways.Try them out in the Python interpreter if you're not sure
Outline hersey and blanchard situational leadership model : The Director of Human Resources of Baptist Health System, an integrated network of non-profit hospitals, physician clinics, and home medical services with over
Basic product in introductory stage of lifecycle : Describe the basic product in the introductory stage of the lifecycle. how would you now describe the product?
What is the contribution margin per the constrained resource : What is the contribution margin per the constrained resource for table saw blades
Means of expressing management : Critical writers suggest that leadership is simply a means of expressing management in a way that employees would find more acceptable and therefore work harder

Reviews

Write a Review

Python Programming Questions & Answers

  Design data pipeline assessment

Identify best practices in data collection and storage, including data security and privacy principles; and Effectively report and communicate findings

  Write a program that computes the circumference of a circle

Write a program that computes the circumference of a circle with a radius of 7.5 and prints out the result. The circumference is 2* pi * radius.

  Write a program that will ask the user to input the names

Write a program that will ask the user to input the names of cities they would like to visit.

  Why you chose the type of control structures and loops

Write algorithm using pseudocode for the the following action: Prompting the user to input a set of grades and print the highest value, minimum value.

  Determine the length of the entered string

Determine the length of the entered string and do one of the following: If it is zero characters in length output the message.

  Describe the original data for the city you are observing

Describe the original data for the city you are observing. Regression Analysis Hypothesis testing. Explain the hypothesis and the result by graph.

  Find the next unmarked number d

We have a list that tells us if any of the numbers 0..maxn are "marked". It can be an array of booleans. The zero and one slots are not used.

  What is a python development framework

What's a python development framework? give 3 examples python development framework used today.

  Write a python program that performs simple encryption

You are required to write a Python program that performs simple encryption and decryption on strings entered by the user. To do so, you are to use one of the simplest and most widely known encryption techniques known as the Caesar Cipher

  Write a function draw which prints a line of n occurrences

Write a function showMax(a, b, c) which prints the largest of distinct integers a, b, and c to the screen. Write an interactive script to test showMax.

  The dictionary order based on the ascii order

Needless to say, the dictionary order based on the ASCII order is not what a real-world indexing software wants. So, we want to implement the dictionary order of strings in the standard wa

  Write new python program that contains a main function

Start with a comment that includes your name and course number. Include pseudocode that describes all steps required to solve the problem.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd