Draw the activity diagram of autonomous cars project in draw.io online software?
write a code which displays the amount of movies ticket bought by the customer and the seat number .write using functions
These are compilers questions
1. C language is an example of imperative / procedural language, but since it is old (no OO or functional programming allowed), is no more required to industry.
a. True
b. False
2. Considering an ANSI C compiler what can represent a lexical error?
a. a = )a+(b;
b. a = 0.0a;
c. if (a=3) a++;
d. a = α{"version":"1.1","math":"α"}~b;
When you are setting a bit flag (position "p"), what is the mask that you need to use and what is the operation required? What is supposed to be the mask value for reset and what is the operation? Give one example.
In the buffer code, identify the problems if:
(a) You do not use a temporary variable to realloc buffer;
(b) You do not test the buffer before each function.
(c) You do not free the memory in case of error
In buffer, what is the purpose for setting bits EOB (end of buffer) and RLC (rellocation) and in which functions it is supposed to happen?
# Looks great! # . I would come up with a better name for d
# test if the user wants to quit...
# Is not quite right... Change this print('I thought of another number, try again')
# to something more like "Not Quite, Please try again"
from random import randint
play = input('You want to start? y/n ')
def play_game():
# Put the rules here
# While loop goes here
d = randint(7, 50)
computer_num = randint(1, d)
lives = d // 2
while lives > 0:
try:
num = int(input(f'enter number from 1 to {d}, you have {lives} attempts left '))
if num > d or num < 1:
raise ValueError
except:
print('incorrect input, try again')
continue
if num == computer_num:
print(f'you won, I thought number {computer_num}')
return None
else:
lives -= 1
if lives > 0:
print('I thought of another number, try again')
print(f'you lost, I thought number {computer_num}')
play = input('You want to start the game[y/n]: ')
while play.lower() == 'y':
play_game()
play = input('You want to play again? y/n ')Exercise 2: Battery Model
it is capable of storing, and the energy it is currently storing (in joules).
(b) Define a function PowerDevice that takes as arguments: a current of an electrical device (amps), a battery of type
BatteryModel, and the time the device is to be powered by the battery (seconds), and determines whether the battery's
energy reserve is adequate to power the device.
If so, the function updates its reserve by subtracting the energy consumed
and returns the value 1.
Otherwise it returns the value 0 and leaves the energy reserve unchanged.
(c) Define a function MaxTime that takes as arguments: a current of an electrical device and a battery of type BatteryModel,
and returns the number of seconds this battery can operate the device before it is fully discharged.
(d) Define a function Recharge that sets a battery of type BatteryModel representing the present energy reserve to its maxi-
the battery's remaining energy could power an 8-A device.
1. C language is an example of imperative / procedural language, but since it is old (no OO or functional programming allowed), is no more required to industry.
True or False
2. Considering an ANSI C compiler what can represent a lexical error?
a. a = )a+(b;
b. a = 0.0a;
c. if (a=3) a++;
d. a = α{"version":"1.1","math":"α"}~b;
Theory questions about Compilers
1 When you are setting a bit flag (position "p"), what is the mask that you need to use and what is the operation required? What is supposed to be the mask value for reset and what is the operation? Give one example.
2.
In the buffer code, identify the problems if:
(a) You do not use a temporary variable to realloc buffer;
(b) You do not test the buffer before each function.
(c) You do not free the memory in case of error
3. In buffer, what is the purpose for setting bits EOB (end of buffer) and RLC (rellocation) and in which functions it is supposed to happen?
4. Is it possible to change buffer.h constants and typedefs that do not require modifications in the code of buffer.c? Explain and give an example.